From 20e4cc3b6f4f36745c3eb18de1664f8e04083e14 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 17 Feb 2020 11:23:15 +0100 Subject: [PATCH] Fix finding replacers/providers to check constraints correctly --- src/Composer/Repository/InstalledRepository.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Composer/Repository/InstalledRepository.php b/src/Composer/Repository/InstalledRepository.php index 13cd572f8..3d305ae39 100644 --- a/src/Composer/Repository/InstalledRepository.php +++ b/src/Composer/Repository/InstalledRepository.php @@ -44,8 +44,19 @@ class InstalledRepository extends CompositeRepository foreach ($this->getRepositories() as $repo) { foreach ($repo->getPackages() as $candidate) { if (in_array($name, $candidate->getNames(), true)) { - if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) { + if (null === $constraint) { $matches[] = $candidate; + continue; + } + if ($name === $candidate->getName() && $constraint->matches(new Constraint('==', $candidate->getVersion()))) { + $matches[] = $candidate; + continue; + } + foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) { + if ($name === $link->getTarget() && ($link->getConstraint() === null || $constraint->matches($link->getConstraint()))) { + $matches[] = $candidate; + continue; + } } } }