From 8da3b3b9be116f9d3084438d5b33e58acd801240 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 24 Feb 2021 16:36:09 +0100 Subject: [PATCH] List relevant conflicts in why/why-not, fixes #9693 --- src/Composer/Repository/InstalledRepository.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Composer/Repository/InstalledRepository.php b/src/Composer/Repository/InstalledRepository.php index d7ffe92d1..7405a30bb 100644 --- a/src/Composer/Repository/InstalledRepository.php +++ b/src/Composer/Repository/InstalledRepository.php @@ -165,6 +165,18 @@ class InstalledRepository extends CompositeRepository } } + // List conflicts against X as they may explain why the current version was selected, or explain why it is rejected if the conflict matched when inverting + foreach ($package->getConflicts() as $link) { + if (in_array($link->getTarget(), $needles)) { + foreach ($this->findPackages($link->getTarget()) as $pkg) { + $version = new Constraint('=', $pkg->getVersion()); + if ($link->getConstraint()->matches($version) === $invert) { + $results[] = array($package, $link, false); + } + } + } + } + // When inverting, we need to check for conflicts of the needles' requirements against installed packages if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) { foreach ($package->getRequires() as $link) {