1
0
Fork 0

Separate createPool and createPoolWithAllPackages, fix test description

pull/8684/head
Nils Adermann 2020-03-12 13:17:04 +01:00
parent 3ec59204fc
commit ee8df484c4
3 changed files with 27 additions and 13 deletions

View File

@ -565,7 +565,7 @@ class Installer
$request->requireName($link->getTarget(), $link->getConstraint()); $request->requireName($link->getTarget(), $link->getConstraint());
} }
$pool = $repositorySet->createPool($request, $this->eventDispatcher, true); $pool = $repositorySet->createPoolWithAllPackages();
$solver = new Solver($policy, $pool, $this->io, $repositorySet); $solver = new Solver($policy, $pool, $this->io, $repositorySet);
try { try {

View File

@ -200,7 +200,27 @@ class RepositorySet
* *
* @return Pool * @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) { foreach ($this->repositories as $repo) {
if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) { if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
@ -210,7 +230,6 @@ class RepositorySet
$this->locked = true; $this->locked = true;
if ($allPackages) {
$packages = array(); $packages = array();
foreach ($this->repositories as $repository) { foreach ($this->repositories as $repository) {
$packages = array_merge($packages, $repository->getPackages()); $packages = array_merge($packages, $repository->getPackages());
@ -218,11 +237,6 @@ class RepositorySet
return new Pool($packages); return new Pool($packages);
} }
$poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $eventDispatcher);
return $poolBuilder->buildPool($this->repositories, $request);
}
// TODO unify this with above in some simpler version without "request"? // TODO unify this with above in some simpler version without "request"?
public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null) public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
{ {

View File

@ -1,5 +1,5 @@
--TEST-- --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-- --COMPOSER--
{ {
"repositories": [ "repositories": [