diff --git a/src/Composer/DependencyResolver/Pool.php b/src/Composer/DependencyResolver/Pool.php index e62d03999..9470c6e35 100644 --- a/src/Composer/DependencyResolver/Pool.php +++ b/src/Composer/DependencyResolver/Pool.php @@ -32,20 +32,16 @@ class Pool implements \Countable const MATCH = 1; const MATCH_PROVIDE = 2; const MATCH_REPLACE = 3; - const MATCH_FILTERED = 4; - protected $providerRepos = array(); protected $packages = array(); protected $packageByName = array(); protected $packageByExactName = array(); protected $priorities = array(); protected $versionParser; protected $providerCache = array(); - protected $filterRequires; - public function __construct(array $filterRequires = array()) + public function __construct() { - $this->filterRequires = $filterRequires; $this->versionParser = new VersionParser; } @@ -99,27 +95,22 @@ class Pool implements \Countable * packages must match or null to return all * @param bool $mustMatchName Whether the name of returned packages * must match the given name - * @param bool $bypassFilters If enabled, filterRequires and stability matching is ignored * @return PackageInterface[] A set of packages */ - public function whatProvides($name, ConstraintInterface $constraint = null, $mustMatchName = false, $bypassFilters = false) + public function whatProvides($name, ConstraintInterface $constraint = null, $mustMatchName = false) { - if ($bypassFilters) { - return $this->computeWhatProvides($name, $constraint, $mustMatchName, true); - } - $key = ((int) $mustMatchName).$constraint; if (isset($this->providerCache[$name][$key])) { return $this->providerCache[$name][$key]; } - return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint, $mustMatchName, $bypassFilters); + return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint, $mustMatchName); } /** * @see whatProvides */ - private function computeWhatProvides($name, $constraint, $mustMatchName = false, $bypassFilters = false) + private function computeWhatProvides($name, $constraint, $mustMatchName = false) { $candidates = array(); @@ -135,7 +126,7 @@ class Pool implements \Countable $nameMatch = false; foreach ($candidates as $candidate) { - switch ($this->match($candidate, $name, $constraint, $bypassFilters)) { + switch ($this->match($candidate, $name, $constraint)) { case self::MATCH_NONE: break; @@ -156,9 +147,6 @@ class Pool implements \Countable $matches[] = $candidate; break; - case self::MATCH_FILTERED: - break; - default: throw new \UnexpectedValueException('Unexpected match type'); } @@ -201,24 +189,16 @@ class Pool implements \Countable * @param ConstraintInterface $constraint The constraint to verify * @return int One of the MATCH* constants of this class or 0 if there is no match */ - public function match($candidate, $name, ConstraintInterface $constraint = null, $bypassFilters) + public function match($candidate, $name, ConstraintInterface $constraint = null) { $candidateName = $candidate->getName(); $candidateVersion = $candidate->getVersion(); - $isDev = $candidate->getStability() === 'dev'; - $isAlias = $candidate instanceof AliasPackage; - - if (!$bypassFilters && !$isDev && !$isAlias && isset($this->filterRequires[$name])) { - $requireFilter = $this->filterRequires[$name]; - } else { - $requireFilter = new EmptyConstraint; - } if ($candidateName === $name) { $pkgConstraint = new Constraint('==', $candidateVersion); if ($constraint === null || $constraint->matches($pkgConstraint)) { - return $requireFilter->matches($pkgConstraint) ? self::MATCH : self::MATCH_FILTERED; + return self::MATCH; } return self::MATCH_NAME; @@ -231,13 +211,13 @@ class Pool implements \Countable if (isset($replaces[0]) || isset($provides[0])) { foreach ($provides as $link) { if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) { - return $requireFilter->matches($link->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED; + return self::MATCH_PROVIDE; } } foreach ($replaces as $link) { if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) { - return $requireFilter->matches($link->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED; + return self::MATCH_REPLACE; } } @@ -245,11 +225,11 @@ class Pool implements \Countable } if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) { - return $requireFilter->matches($provides[$name]->getConstraint()) ? self::MATCH_PROVIDE : self::MATCH_FILTERED; + return self::MATCH_PROVIDE; } if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) { - return $requireFilter->matches($replaces[$name]->getConstraint()) ? self::MATCH_REPLACE : self::MATCH_FILTERED; + return self::MATCH_REPLACE; } return self::MATCH_NONE; diff --git a/src/Composer/DependencyResolver/PoolBuilder.php b/src/Composer/DependencyResolver/PoolBuilder.php index b2f596bbd..7b80c41bd 100644 --- a/src/Composer/DependencyResolver/PoolBuilder.php +++ b/src/Composer/DependencyResolver/PoolBuilder.php @@ -28,7 +28,7 @@ use Composer\Semver\Constraint\MultiConstraint; class PoolBuilder { private $isPackageAcceptableCallable; - private $filterRequires; + private $rootRequires; private $rootAliases; private $rootReferences; @@ -40,15 +40,15 @@ class PoolBuilder private $packages = array(); private $priorities = array(); - public function __construct($isPackageAcceptableCallable, array $filterRequires = array()) + public function __construct($isPackageAcceptableCallable, array $rootRequires = array()) { $this->isPackageAcceptableCallable = $isPackageAcceptableCallable; - $this->filterRequires = $filterRequires; + $this->rootRequires = $rootRequires; } public function buildPool(array $repositories, array $rootAliases, array $rootReferences, Request $request) { - $pool = new Pool($this->filterRequires); + $pool = new Pool(); $this->rootAliases = $rootAliases; $this->rootReferences = $rootReferences; diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index c2c3f42c6..8c73bd91d 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -148,13 +148,15 @@ class Problem return "\n - The requested package ".$packageName.' could not be found, it looks like its name is invalid, "'.$illegalChars.'" is not allowed in package names.'; } - if ($providers = $this->pool->whatProvides($packageName, $constraint, true, true)) { + // TODO: The pool doesn't know about these anymore, it has to ask the RepositorySet + /*if ($providers = $this->pool->whatProvides($packageName, $constraint, true, true)) { return "\n - The requested package ".$packageName.$this->constraintToText($constraint).' is satisfiable by '.$this->getPackageList($providers).' but these conflict with your requirements or minimum-stability.'; - } + }*/ - if ($providers = $this->pool->whatProvides($packageName, null, true, true)) { + // TODO: The pool doesn't know about these anymore, it has to ask the RepositorySet + /*if ($providers = $this->pool->whatProvides($packageName, null, true, true)) { return "\n - The requested package ".$packageName.$this->constraintToText($constraint).' exists as '.$this->getPackageList($providers).' but these are rejected by your constraint.'; - } + }*/ return "\n - The requested package ".$packageName.' could not be found in any version, there may be a typo in the package name.'; } diff --git a/src/Composer/DependencyResolver/Rule.php b/src/Composer/DependencyResolver/Rule.php index c238f59fa..7a12664db 100644 --- a/src/Composer/DependencyResolver/Rule.php +++ b/src/Composer/DependencyResolver/Rule.php @@ -217,9 +217,10 @@ abstract class Rule return $text . ' -> the requested linked library '.$lib.' has the wrong version installed or is missing from your system, make sure to have the extension providing it.'; } - if ($providers = $pool->whatProvides($targetName, $this->reasonData->getConstraint(), true, true)) { + // TODO: The pool doesn't know about these anymore, it has to ask the RepositorySet + /*if ($providers = $pool->whatProvides($targetName, $this->reasonData->getConstraint(), true, true)) { return $text . ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $providers) .' but these conflict with your requirements or minimum-stability.'; - } + }*/ return $text . ' -> no matching package found.'; } diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 60cde1a76..87412f7ea 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -717,16 +717,16 @@ class Installer } } - $rootConstraints = array(); + $rootRequires = array(); foreach ($requires as $req => $constraint) { // skip platform requirements from the root package to avoid filtering out existing platform packages if ($this->ignorePlatformReqs && preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $req)) { continue; } if ($constraint instanceof Link) { - $rootConstraints[$req] = $constraint->getConstraint(); + $rootRequires[$req] = $constraint->getConstraint(); } else { - $rootConstraints[$req] = $constraint; + $rootRequires[$req] = $constraint; } } @@ -734,7 +734,7 @@ class Installer $this->fixedRootPackage->setRequires(array()); $this->fixedRootPackage->setDevRequires(array()); - $repositorySet = new RepositorySet($rootAliases, $this->package->getReferences(), $minimumStability, $stabilityFlags, $rootConstraints); + $repositorySet = new RepositorySet($rootAliases, $this->package->getReferences(), $minimumStability, $stabilityFlags, $rootRequires); $repositorySet->addRepository(new InstalledArrayRepository(array($this->fixedRootPackage))); $repositorySet->addRepository($platformRepo); if ($this->additionalFixedRepository) { diff --git a/src/Composer/Repository/RepositorySet.php b/src/Composer/Repository/RepositorySet.php index f7f8a57f8..21526b96f 100644 --- a/src/Composer/Repository/RepositorySet.php +++ b/src/Composer/Repository/RepositorySet.php @@ -37,12 +37,12 @@ class RepositorySet private $acceptableStabilities; private $stabilityFlags; - protected $filterRequires; + protected $rootRequires; /** @var Pool */ private $pool; - public function __construct(array $rootAliases = array(), array $rootReferences = array(), $minimumStability = 'stable', array $stabilityFlags = array(), array $filterRequires = array()) + public function __construct(array $rootAliases = array(), array $rootReferences = array(), $minimumStability = 'stable', array $stabilityFlags = array(), array $rootRequires = array()) { $this->rootAliases = $rootAliases; $this->rootReferences = $rootReferences; @@ -54,10 +54,10 @@ class RepositorySet } } $this->stabilityFlags = $stabilityFlags; - $this->filterRequires = $filterRequires; - foreach ($filterRequires as $name => $constraint) { + $this->rootRequires = $rootRequires; + foreach ($rootRequires as $name => $constraint) { if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name)) { - unset($this->filterRequires[$name]); + unset($this->rootRequires[$name]); } } } @@ -152,7 +152,7 @@ class RepositorySet */ public function createPool(Request $request) { - $poolBuilder = new PoolBuilder(array($this, 'isPackageAcceptable'), $this->filterRequires); + $poolBuilder = new PoolBuilder(array($this, 'isPackageAcceptable'), $this->rootRequires); return $this->pool = $poolBuilder->buildPool($this->repositories, $this->rootAliases, $this->rootReferences, $request); } diff --git a/tests/Composer/Test/Fixtures/installer/solver-problems.test b/tests/Composer/Test/Fixtures/installer/solver-problems.test index 94a0e3aa3..57d3ced92 100644 --- a/tests/Composer/Test/Fixtures/installer/solver-problems.test +++ b/tests/Composer/Test/Fixtures/installer/solver-problems.test @@ -65,7 +65,7 @@ Your requirements could not be resolved to an installable set of packages. - requirer/pkg 1.0.0 requires dependency/pkg 1.0.0 -> no matching package found. Problem 4 - stable-requiree-excluded/pkg is locked to version 1.0.0 and an update of this package was not requested. - - Same name, can only install one of: stable-requiree-excluded/pkg[1.0.1, 1.0.0]. + - Same name, can only install one of: stable-requiree-excluded/pkg[1.0.0, 1.0.1]. - Installation request for stable-requiree-excluded/pkg 1.0.1 -> satisfiable by stable-requiree-excluded/pkg[1.0.1]. Potential causes: