mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Merge pull request #8937 from Seldaek/optim-rules
Optimize rule creation for alias packages
This commit is contained in:
commit
a66a939b76
4 changed files with 18 additions and 3 deletions
|
@ -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) {
|
||||
|
|
|
@ -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 *
|
||||
***************************************/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue