diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 1f016ab00..099ca2792 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -139,9 +139,13 @@ class Installer } foreach ($aliases as $alias) { foreach ($this->repositoryManager->findPackages($alias['package'], $alias['version']) as $package) { + $package->setAlias($alias['alias_normalized']); + $package->setPrettyAlias($alias['alias']); $package->getRepository()->addPackage(new AliasPackage($package, $alias['alias_normalized'], $alias['alias'])); } foreach ($this->repositoryManager->getLocalRepository()->findPackages($alias['package'], $alias['version']) as $package) { + $package->setAlias($alias['alias_normalized']); + $package->setPrettyAlias($alias['alias']); $this->repositoryManager->getLocalRepository()->addPackage(new AliasPackage($package, $alias['alias_normalized'], $alias['alias'])); $this->repositoryManager->getLocalRepository()->removePackage($package); } diff --git a/src/Composer/Repository/ArrayRepository.php b/src/Composer/Repository/ArrayRepository.php index 515f89ea9..1af73d311 100644 --- a/src/Composer/Repository/ArrayRepository.php +++ b/src/Composer/Repository/ArrayRepository.php @@ -102,9 +102,9 @@ class ArrayRepository implements RepositoryInterface } } - protected function createAliasPackage(PackageInterface $package) + protected function createAliasPackage(PackageInterface $package, $alias = null, $prettyAlias = null) { - return new AliasPackage($package, $package->getAlias(), $package->getPrettyAlias()); + return new AliasPackage($package, $alias ?: $package->getAlias(), $prettyAlias ?: $package->getPrettyAlias()); } /** diff --git a/src/Composer/Repository/FilesystemRepository.php b/src/Composer/Repository/FilesystemRepository.php index e17134b42..95cb11b4b 100644 --- a/src/Composer/Repository/FilesystemRepository.php +++ b/src/Composer/Repository/FilesystemRepository.php @@ -59,8 +59,11 @@ class FilesystemRepository extends ArrayRepository implements WritableRepository // package was installed as alias, so we only add the alias if ($this instanceof InstalledRepositoryInterface && !empty($packageData['installed-as-alias'])) { + $alias = $packageData['installed-as-alias']; + $package->setAlias($alias); + $package->setPrettyAlias($alias); $package->setInstalledAsAlias(true); - $this->addPackage($this->createAliasPackage($package)); + $this->addPackage($this->createAliasPackage($package, $alias, $alias)); } else { // only add regular package - if it's not an installed repo the alias will be created on the fly $this->addPackage($package); @@ -78,7 +81,7 @@ class FilesystemRepository extends ArrayRepository implements WritableRepository foreach ($this->getPackages() as $package) { $data = $dumper->dump($package); if ($this instanceof InstalledRepositoryInterface && $package->isInstalledAsAlias()) { - $data['installed-as-alias'] = true; + $data['installed-as-alias'] = $package->getAlias(); } $packages[] = $data; }