1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-10 09:02:59 +00:00

Improve error reporting of solver issues, refs #7779

Fixes #8525
Fixes #6513
This commit is contained in:
Jordi Boggiano 2020-01-29 22:47:16 +01:00
parent f611c641db
commit 3fc7e10c5c
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC
34 changed files with 482 additions and 223 deletions

View file

@ -29,6 +29,19 @@ use Composer\Package\Version\StabilityFilter;
*/
class RepositorySet
{
/**
* Packages which replace/provide the given name might be returned as well even if they do not match the name exactly
*/
const ALLOW_PROVIDERS_REPLACERS = 1;
/**
* Packages are returned even though their stability does not match the required stability
*/
const ALLOW_UNACCEPTABLE_STABILITIES = 2;
/**
* Packages will be looked up in all repositories, even after they have been found in a higher prio one
*/
const ALLOW_SHADOWED_REPOSITORIES = 4;
/** @var array */
private $rootAliases;
/** @var array */
@ -39,7 +52,7 @@ class RepositorySet
private $acceptableStabilities;
private $stabilityFlags;
protected $rootRequires;
private $rootRequires;
/** @var Pool */
private $pool;
@ -64,6 +77,11 @@ class RepositorySet
}
}
public function getRootRequires()
{
return $this->rootRequires;
}
/**
* Adds a repository to this repository set
*
@ -96,15 +114,32 @@ class RepositorySet
*
* @param string $name
* @param ConstraintInterface|null $constraint
* @param bool $exactMatch if set to false, packages which replace/provide the given name might be returned as well even if they do not match the name exactly
* @param bool $ignoreStability if set to true, packages are returned even though their stability does not match the required stability
* @param int $flags any of the ALLOW_* constants from this class to tweak what is returned
* @return array
*/
public function findPackages($name, ConstraintInterface $constraint = null, $exactMatch = true, $ignoreStability = false)
public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0)
{
$exactMatch = ($flags & self::ALLOW_PROVIDERS_REPLACERS) === 0;
$ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
$loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
$packages = array();
foreach ($this->repositories as $repository) {
$packages[] = $repository->findPackages($name, $constraint) ?: array();
if ($loadFromAllRepos) {
foreach ($this->repositories as $repository) {
$packages[] = $repository->findPackages($name, $constraint) ?: array();
}
} else {
foreach ($this->repositories as $repository) {
$result = $repository->loadPackages(array($name => $constraint), $ignoreStability ? BasePackage::$stabilities : $this->acceptableStabilities, $ignoreStability ? array() : $this->stabilityFlags);
$packages[] = $result['packages'];
foreach ($result['namesFound'] as $nameFound) {
// avoid loading the same package again from other repositories once it has been found
if ($name === $nameFound) {
break 2;
}
}
}
}
$candidates = $packages ? call_user_func_array('array_merge', $packages) : array();
@ -135,7 +170,7 @@ class RepositorySet
*/
public function createPool(Request $request)
{
$poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $this->rootRequires);
$poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences);
foreach ($this->repositories as $repo) {
if ($repo instanceof InstalledRepositoryInterface) {