From cfd0e443126e695b787313d736a7d4945c08bdf1 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 5 May 2015 20:28:22 +0200 Subject: [PATCH] Move private function further down in pool --- src/Composer/DependencyResolver/Pool.php | 81 +++++++++++++----------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/src/Composer/DependencyResolver/Pool.php b/src/Composer/DependencyResolver/Pool.php index 566c6e262..222c414cb 100644 --- a/src/Composer/DependencyResolver/Pool.php +++ b/src/Composer/DependencyResolver/Pool.php @@ -107,44 +107,6 @@ class Pool } } - private function loadPackage(PackageInterface $package, array $rootAliases, $acceptableExemption = false) - { - $names = $package->getNames(); - $stability = $package->getStability(); - - if (!$acceptableExemption && !$this->isPackageAcceptable($names, $stability)) { - return; - } - - $package->setId($this->id++); - $this->packages[] = $package; - $this->packageByExactName[$package->getName()][$package->id] = $package; - - foreach ($names as $provided) { - $this->packageByName[$provided][] = $package; - } - - // handle root package aliases - $name = $package->getName(); - if (isset($rootAliases[$name][$package->getVersion()])) { - $alias = $rootAliases[$name][$package->getVersion()]; - if ($package instanceof AliasPackage) { - $package = $package->getAliasOf(); - } - $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']); - $aliasPackage->setRootPackageAlias(true); - $aliasPackage->setId($this->id++); - - $package->getRepository()->addPackage($aliasPackage); - $this->packages[] = $aliasPackage; - $this->packageByExactName[$aliasPackage->getName()][$aliasPackage->id] = $aliasPackage; - - foreach ($aliasPackage->getNames() as $name) { - $this->packageByName[$name][] = $aliasPackage; - } - } - } - public function getPriority(RepositoryInterface $repo) { $priority = array_search($repo, $this->repositories, true); @@ -167,6 +129,11 @@ class Pool return $this->packages[$id - 1]; } + /** + * Ensures that all given names and their requirements are loaded. + * + * @param array $packageNames A list of names that need to be available + */ public function loadRecursively(array $packageNames) { $loadedMap = array(); @@ -214,6 +181,44 @@ class Pool return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint, $mustMatchName); } + private function loadPackage(PackageInterface $package, array $rootAliases, $acceptableExemption = false) + { + $names = $package->getNames(); + $stability = $package->getStability(); + + if (!$acceptableExemption && !$this->isPackageAcceptable($names, $stability)) { + return; + } + + $package->setId($this->id++); + $this->packages[] = $package; + $this->packageByExactName[$package->getName()][$package->id] = $package; + + foreach ($names as $provided) { + $this->packageByName[$provided][] = $package; + } + + // handle root package aliases + $name = $package->getName(); + if (isset($rootAliases[$name][$package->getVersion()])) { + $alias = $rootAliases[$name][$package->getVersion()]; + if ($package instanceof AliasPackage) { + $package = $package->getAliasOf(); + } + $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']); + $aliasPackage->setRootPackageAlias(true); + $aliasPackage->setId($this->id++); + + $package->getRepository()->addPackage($aliasPackage); + $this->packages[] = $aliasPackage; + $this->packageByExactName[$aliasPackage->getName()][$aliasPackage->id] = $aliasPackage; + + foreach ($aliasPackage->getNames() as $name) { + $this->packageByName[$name][] = $aliasPackage; + } + } + } + /** * @see whatProvides */