Pārlūkot izejas kodu

Refactored the search of suggested packages to support replacements

Fixes #752
Christophe Coevoet 12 gadi atpakaļ
vecāks
revīzija
d0faa016c1
1 mainītis faili ar 10 papildinājumiem un 1 dzēšanām
  1. 10 1
      src/Composer/Installer.php

+ 10 - 1
src/Composer/Installer.php

@@ -188,7 +188,16 @@ class Installer
 
 
         // output suggestions
         // output suggestions
         foreach ($this->suggestedPackages as $suggestion) {
         foreach ($this->suggestedPackages as $suggestion) {
-            if (!$installedRepo->findPackages($suggestion['target'])) {
+            $target = $suggestion['target'];
+            if ($installedRepo->filterPackages(function (PackageInterface $package) use ($target) {
+                // check the name first as it is the common case
+                if ($package->getName() === $target) {
+                    return false;
+                }
+                if (in_array($target, $package->getNames())) {
+                    return false;
+                }
+            })) {
                 $this->io->write($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')');
                 $this->io->write($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')');
             }
             }
         }
         }