1
0
Fork 0

Optimize rule creation for alias packages

This mainly benefits projects running updates with minimum-stability: dev
pull/8937/head
Jordi Boggiano 2020-06-02 13:44:56 +02:00
parent 8a7f3a9a09
commit 5a4709c3d6
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
4 changed files with 18 additions and 3 deletions

View File

@ -167,6 +167,12 @@ class RuleSetGenerator
} else {
$workQueue->enqueue($package->getAliasOf());
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, array($package->getAliasOf()), Rule::RULE_PACKAGE_ALIAS, $package));
// if alias package has no self.version requires, its requirements do not
// need to be added as the aliased package processing will take care of it
if (!$package->hasSelfVersionRequires()) {
continue;
}
}
foreach ($package->getRequires() as $link) {

View File

@ -25,6 +25,7 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
protected $dev;
protected $rootPackageAlias = false;
protected $stability;
protected $hasSelfVersionRequires = false;
/** @var PackageInterface */
protected $aliasOf;
@ -192,6 +193,9 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
} else {
foreach ($links as $index => $link) {
if ('self.version' === $link->getPrettyConstraint()) {
if ($linkType === 'requires') {
$this->hasSelfVersionRequires = true;
}
$links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
$constraint->setPrettyString($prettyVersion);
}
@ -201,6 +205,11 @@ class AliasPackage extends BasePackage implements CompletePackageInterface
return $links;
}
public function hasSelfVersionRequires()
{
return $this->hasSelfVersionRequires;
}
/***************************************
* Wrappers around the aliased package *
***************************************/

View File

@ -48,9 +48,9 @@ Your requirements could not be resolved to an installable set of packages.
- Root composer.json requires b/b *@dev -> satisfiable by b/b[dev-master].
- a/a dev-master requires d/d 1.0.0 -> satisfiable by d/d[1.0.0].
- You can only install one version of a package, so only one of these can be installed: d/d[1.0.0, 2.0.0].
- Conclusion: install d/d 2.0.0, learned rules:
- Root composer.json requires b/b *@dev -> satisfiable by b/b[dev-master].
- b/b dev-master requires d/d 2.0.0 -> satisfiable by d/d[2.0.0].
- Conclusion: install b/b dev-master, learned rules:
- Root composer.json requires b/b *@dev -> satisfiable by b/b[dev-master].
- Root composer.json requires a/a *@dev -> satisfiable by a/a[dev-master].
--EXPECT--

View File

@ -47,7 +47,7 @@ Your requirements could not be resolved to an installable set of packages.
- locked/pkg dev-master requires locked/dependency 1.0.0 -> found locked/dependency[1.0.0] in lock file but not in remote repositories, make sure you avoid updating this package to keep the one from lock file.
Problem 2
- locked/pkg dev-master requires locked/dependency 1.0.0 -> found locked/dependency[1.0.0] in lock file but not in remote repositories, make sure you avoid updating this package to keep the one from lock file.
- Root composer.json requires locked/pkg *@dev -> satisfiable by locked/pkg[dev-master].
- locked/pkg is locked to version dev-master and an update of this package was not requested.
Use the option --with-all-dependencies to allow upgrades, downgrades and removals for packages currently locked to specific versions.
--EXPECT--