From ee8df484c42ab6df0f4434864c98d141d9792757 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Thu, 12 Mar 2020 13:17:04 +0100 Subject: [PATCH] Separate createPool and createPoolWithAllPackages, fix test description --- src/Composer/Installer.php | 2 +- src/Composer/Repository/RepositorySet.php | 36 +++++++++++++------ ...vider-dev-require-can-satisfy-require.test | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 2bb38f885..ba06f44e9 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -565,7 +565,7 @@ class Installer $request->requireName($link->getTarget(), $link->getConstraint()); } - $pool = $repositorySet->createPool($request, $this->eventDispatcher, true); + $pool = $repositorySet->createPoolWithAllPackages(); $solver = new Solver($policy, $pool, $this->io, $repositorySet); try { diff --git a/src/Composer/Repository/RepositorySet.php b/src/Composer/Repository/RepositorySet.php index b0d4153cd..a05906d68 100644 --- a/src/Composer/Repository/RepositorySet.php +++ b/src/Composer/Repository/RepositorySet.php @@ -200,7 +200,27 @@ class RepositorySet * * @return Pool */ - public function createPool(Request $request, EventDispatcher $eventDispatcher = null, $allPackages = false) + public function createPool(Request $request, EventDispatcher $eventDispatcher = null) + { + $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $eventDispatcher); + + foreach ($this->repositories as $repo) { + if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) { + throw new \LogicException('The pool can not accept packages from an installed repository'); + } + } + + $this->locked = true; + + return $poolBuilder->buildPool($this->repositories, $request); + } + + /** + * Create a pool for dependency resolution from the packages in this repository set. + * + * @return Pool + */ + public function createPoolWithAllPackages() { foreach ($this->repositories as $repo) { if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) { @@ -210,17 +230,11 @@ class RepositorySet $this->locked = true; - if ($allPackages) { - $packages = array(); - foreach ($this->repositories as $repository) { - $packages = array_merge($packages, $repository->getPackages()); - } - return new Pool($packages); + $packages = array(); + foreach ($this->repositories as $repository) { + $packages = array_merge($packages, $repository->getPackages()); } - - $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $eventDispatcher); - - return $poolBuilder->buildPool($this->repositories, $request); + return new Pool($packages); } // TODO unify this with above in some simpler version without "request"? diff --git a/tests/Composer/Test/Fixtures/installer/provider-dev-require-can-satisfy-require.test b/tests/Composer/Test/Fixtures/installer/provider-dev-require-can-satisfy-require.test index 8d29112f0..b5d3fefe7 100644 --- a/tests/Composer/Test/Fixtures/installer/provider-dev-require-can-satisfy-require.test +++ b/tests/Composer/Test/Fixtures/installer/provider-dev-require-can-satisfy-require.test @@ -1,5 +1,5 @@ --TEST-- -Test that an appropriate error is thrown if a requirement is only satisfied by a package provided by a dependency of a dev requirement. +Test that a requirement can be satisfied by a providing package required in require-dev. --COMPOSER-- { "repositories": [