From 95e6e16b78b62e104247d4850f60c92bc9b2076f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 29 Apr 2020 01:47:29 +0200 Subject: [PATCH] Use Semver compiled constraints --- src/Composer/DependencyResolver/Pool.php | 5 ++--- src/Composer/DependencyResolver/PoolBuilder.php | 10 +++++----- src/Composer/Repository/ComposerRepository.php | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Composer/DependencyResolver/Pool.php b/src/Composer/DependencyResolver/Pool.php index 26ca947d3..b46447f72 100644 --- a/src/Composer/DependencyResolver/Pool.php +++ b/src/Composer/DependencyResolver/Pool.php @@ -14,6 +14,7 @@ namespace Composer\DependencyResolver; use Composer\Package\AliasPackage; use Composer\Package\Version\VersionParser; +use Composer\Semver\CompilingMatcher; use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\Constraint; use Composer\Package\PackageInterface; @@ -146,9 +147,7 @@ class Pool implements \Countable $candidateVersion = $candidate->getVersion(); if ($candidateName === $name) { - $pkgConstraint = new Constraint('==', $candidateVersion); - - if ($constraint === null || $constraint->matches($pkgConstraint)) { + if ($constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion)) { return true; } diff --git a/src/Composer/DependencyResolver/PoolBuilder.php b/src/Composer/DependencyResolver/PoolBuilder.php index 9e1f9f433..1e08e0ad7 100644 --- a/src/Composer/DependencyResolver/PoolBuilder.php +++ b/src/Composer/DependencyResolver/PoolBuilder.php @@ -12,21 +12,21 @@ namespace Composer\DependencyResolver; +use Composer\EventDispatcher\EventDispatcher; use Composer\IO\IOInterface; use Composer\Package\AliasPackage; use Composer\Package\BasePackage; -use Composer\Package\Package; use Composer\Package\PackageInterface; use Composer\Package\Version\StabilityFilter; +use Composer\Plugin\PluginEvents; +use Composer\Plugin\PrePoolCreateEvent; use Composer\Repository\PlatformRepository; use Composer\Repository\RootPackageRepository; +use Composer\Semver\CompilingMatcher; use Composer\Semver\Constraint\Constraint; use Composer\Semver\Constraint\ConstraintInterface; use Composer\Semver\Constraint\MatchAllConstraint; use Composer\Semver\Constraint\MultiConstraint; -use Composer\EventDispatcher\EventDispatcher; -use Composer\Plugin\PrePoolCreateEvent; -use Composer\Plugin\PluginEvents; /** * @author Nils Adermann @@ -209,7 +209,7 @@ class PoolBuilder $found = false; foreach ($aliasedPackages as $packageOrAlias) { - if ($constraint->matches(new Constraint('==', $packageOrAlias->getVersion()))) { + if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) { $found = true; } } diff --git a/src/Composer/Repository/ComposerRepository.php b/src/Composer/Repository/ComposerRepository.php index e960f63be..bb845aeca 100644 --- a/src/Composer/Repository/ComposerRepository.php +++ b/src/Composer/Repository/ComposerRepository.php @@ -23,6 +23,7 @@ use Composer\Config; use Composer\Composer; use Composer\Factory; use Composer\IO\IOInterface; +use Composer\Semver\CompilingMatcher; use Composer\Util\HttpDownloader; use Composer\Util\Loop; use Composer\Plugin\PluginEvents; @@ -764,7 +765,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito continue; } - if ($constraint && !$constraint->matches(new Constraint('==', $version))) { + if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) { continue; }