From 740af2bdb16ce9249da9b7266ee49e67b679f336 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 17 Jul 2022 10:29:56 +0200 Subject: [PATCH] Add warning if constraint appears too narrow, refs #10943 --- src/Composer/Command/InitCommand.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Composer/Command/InitCommand.php b/src/Composer/Command/InitCommand.php index 75bc92dd2..b4ea4350d 100644 --- a/src/Composer/Command/InitCommand.php +++ b/src/Composer/Command/InitCommand.php @@ -530,6 +530,10 @@ EOT $io = $this->getIO(); foreach ($requires as $requirement) { + if (isset($requirement['version']) && Preg::isMatch('{^\d+(\.\d+)?$}', $requirement['version'])) { + $io->writeError('The "'.$requirement['version'].'" constraint for "'.$requirement['name'].'" appears too strict and will likely not match what you want. See https://getcomposer.org/constraints'); + } + if (!isset($requirement['version'])) { // determine the best version automatically list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, null, null, $fixed);