diff --git a/src/Composer/DependencyResolver/PoolBuilder.php b/src/Composer/DependencyResolver/PoolBuilder.php index 4df8b2b83..44f7e2f45 100644 --- a/src/Composer/DependencyResolver/PoolBuilder.php +++ b/src/Composer/DependencyResolver/PoolBuilder.php @@ -34,6 +34,9 @@ class PoolBuilder { private $acceptableStabilities; private $stabilityFlags; + /** + * @psalm-var array> + */ private $rootAliases; private $rootReferences; private $eventDispatcher; @@ -48,11 +51,21 @@ class PoolBuilder private $skippedLoad = array(); private $updateAllowWarned = array(); + /** + * @param int[] $acceptableStabilities array of stability => BasePackage::STABILITY_* value + * @psalm-param array $acceptableStabilities + * @param int[] $stabilityFlags an array of package name => BasePackage::STABILITY_* value + * @psalm-param array $stabilityFlags + * @param array[] $rootAliases + * @psalm-param list $rootAliases + * @param string[] $rootReferences an array of package name => source reference + * @psalm-param array $rootReferences + */ public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, EventDispatcher $eventDispatcher = null) { $this->acceptableStabilities = $acceptableStabilities; $this->stabilityFlags = $stabilityFlags; - $this->rootAliases = $rootAliases; + $this->rootAliases = $this->getRootAliasesPerPackage($rootAliases); $this->rootReferences = $rootReferences; $this->eventDispatcher = $eventDispatcher; $this->io = $io; @@ -372,5 +385,19 @@ class PoolBuilder unset($this->skippedLoad[$name]); unset($this->loadedNames[$name]); } + + private function getRootAliasesPerPackage(array $aliases) + { + $normalizedAliases = array(); + + foreach ($aliases as $alias) { + $normalizedAliases[$alias['package']][$alias['version']] = array( + 'alias' => $alias['alias'], + 'alias_normalized' => $alias['alias_normalized'], + ); + } + + return $normalizedAliases; + } } diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 9f3bd9ac9..7d1da54a4 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -375,14 +375,13 @@ class Installer $this->io->writeError('Updating dependencies'); - $links = array_merge($this->package->getRequires(), $this->package->getDevRequires()); - // if we're updating mirrors we want to keep exactly the same versions installed which are in the lock file, but we want current remote metadata if ($this->updateMirrors) { foreach ($lockedRepository->getPackages() as $lockedPackage) { $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion())); } } else { + $links = array_merge($this->package->getRequires(), $this->package->getDevRequires()); foreach ($links as $link) { $request->requireName($link->getTarget(), $link->getConstraint()); } @@ -824,16 +823,7 @@ class Installer $aliases = $this->locker->getAliases(); } - $normalizedAliases = array(); - - foreach ($aliases as $alias) { - $normalizedAliases[$alias['package']][$alias['version']] = array( - 'alias' => $alias['alias'], - 'alias_normalized' => $alias['alias_normalized'], - ); - } - - return $normalizedAliases; + return $aliases; } /** diff --git a/src/Composer/Plugin/PrePoolCreateEvent.php b/src/Composer/Plugin/PrePoolCreateEvent.php index 0e6617739..d23a644e3 100644 --- a/src/Composer/Plugin/PrePoolCreateEvent.php +++ b/src/Composer/Plugin/PrePoolCreateEvent.php @@ -109,7 +109,8 @@ class PrePoolCreateEvent extends Event } /** - * @return array + * @return array[] of package => version => [alias, alias_normalized] + * @psalm-return array> */ public function getRootAliases() { diff --git a/src/Composer/Repository/RepositorySet.php b/src/Composer/Repository/RepositorySet.php index b0489e99b..24d935f4a 100644 --- a/src/Composer/Repository/RepositorySet.php +++ b/src/Composer/Repository/RepositorySet.php @@ -42,16 +42,33 @@ class RepositorySet */ const ALLOW_SHADOWED_REPOSITORIES = 2; - /** @var array */ + /** + * @var array[] + * @psalm-var list + */ private $rootAliases; - /** @var array */ + + /** + * @var string[] + * @psalm-var array + */ private $rootReferences; /** @var RepositoryInterface[] */ private $repositories = array(); + /** + * @var int[] array of stability => BasePackage::STABILITY_* value + * @psalm-var array + */ private $acceptableStabilities; + + /** + * @var int[] array of package name => BasePackage::STABILITY_* value + * @psalm-var array + */ private $stabilityFlags; + private $rootRequires; /** @var bool */ @@ -59,6 +76,19 @@ class RepositorySet /** @var bool */ private $allowInstalledRepositories = false; + /** + * In most cases if you are looking to use this class as a way to find packages from repositories + * passing minimumStability is all you need to worry about. The rest is for advanced pool creation including + * aliases, pinned references and other special cases. + * + * @param string $minimumStability + * @param int[] $stabilityFlags an array of package name => BasePackage::STABILITY_* value + * @psalm-param array $stabilityFlags + * @param array[] $rootAliases + * @psalm-param list $rootAliases + * @param string[] $rootReferences an array of package name => source reference + * @psalm-param array $rootReferences + */ public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array()) { $this->rootAliases = $rootAliases;