|
39 | 39 | use Composer\Plugin\PrePoolCreateEvent; |
40 | 40 | use Composer\Script\Event; |
41 | 41 | use Composer\Script\ScriptEvents; |
| 42 | +use Composer\Semver\Constraint\Constraint; |
42 | 43 | use Composer\Semver\VersionParser; |
43 | 44 | use Symfony\Component\Console\Exception\ExceptionInterface as ConsoleExceptionInterface; |
44 | 45 | use Symfony\Component\Console\Input\ArgvInput; |
@@ -219,10 +220,14 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__) |
219 | 220 | break; |
220 | 221 | } |
221 | 222 |
|
222 | | - $symfonyRequire = preg_replace('/\.x$/', '.x-dev', getenv('SYMFONY_REQUIRE') ?: ($composer->getPackage()->getExtra()['symfony']['require'] ?? '')); |
| 223 | + $rawSymfonyRequire = getenv('SYMFONY_REQUIRE') ?: ($composer->getPackage()->getExtra()['symfony']['require'] ?? ''); |
| 224 | + $symfonyRequire = preg_replace('/\.x$/', '.x-dev', $rawSymfonyRequire); |
223 | 225 |
|
224 | | - if ($symfonyRequire && preg_match('/^\d+(\.\d+)*$/', $symfonyRequire)) { |
225 | | - $io->writeError(\sprintf('<warning>SYMFONY_REQUIRE="%s" is an exact version constraint. Did you mean "%s.*" or "^%s"?</>', $symfonyRequire, $symfonyRequire, $symfonyRequire)); |
| 226 | + if ($rawSymfonyRequire) { |
| 227 | + $parsedConstraint = (new VersionParser())->parseConstraints($rawSymfonyRequire); |
| 228 | + if ($parsedConstraint instanceof Constraint && '==' === $parsedConstraint->getOperator()) { |
| 229 | + $io->writeError(\sprintf('<warning>SYMFONY_REQUIRE="%s" is an exact version constraint. Did you mean "%s.*" or "^%s"?</>', $rawSymfonyRequire, $rawSymfonyRequire, $rawSymfonyRequire)); |
| 230 | + } |
226 | 231 | } |
227 | 232 |
|
228 | 233 | if ($symfonyRequire || $this->ignorePreleases) { |
|
0 commit comments