diff --git a/src/Composer/DependencyResolver/DefaultPolicy.php b/src/Composer/DependencyResolver/DefaultPolicy.php index 277188238..3659b0a51 100644 --- a/src/Composer/DependencyResolver/DefaultPolicy.php +++ b/src/Composer/DependencyResolver/DefaultPolicy.php @@ -104,6 +104,7 @@ class DefaultPolicy implements PolicyInterface public function compareByPriorityPreferInstalled(Pool $pool, array $installedMap, PackageInterface $a, PackageInterface $b, $ignoreReplace = false) { if ($a->getRepository() === $b->getRepository()) { + // prefer aliases to the original package if ($a->getName() === $b->getName()) { $aAliased = $a instanceof AliasPackage; $bAliased = $b instanceof AliasPackage; diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index 0c0eef3cb..6bd279ecb 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -73,18 +73,18 @@ abstract class BasePackage implements PackageInterface public function getNames() { $names = array( - $this->getName(), + $this->getName() => true, ); foreach ($this->getProvides() as $link) { - $names[] = $link->getTarget(); + $names[$link->getTarget()] = true; } foreach ($this->getReplaces() as $link) { - $names[] = $link->getTarget(); + $names[$link->getTarget()] = true; } - return $names; + return array_keys($names); } /**