function RuleSetGenerator::addConflictRules
1 call to RuleSetGenerator::addConflictRules()
- RuleSetGenerator::getRulesFor in vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ RuleSetGenerator.php
File
-
vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ RuleSetGenerator.php, line 212
Class
- RuleSetGenerator
- @author Nils Adermann <naderman@naderman.de> @phpstan-import-type ReasonData from Rule
Namespace
Composer\DependencyResolverCode
protected function addConflictRules(PlatformRequirementFilterInterface $platformRequirementFilter) : void {
/** @var BasePackage $package */
foreach ($this->addedMap as $package) {
foreach ($package->getConflicts() as $link) {
// even if conflict ends up being with an alias, there would be at least one actual package by this name
if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
continue;
}
$constraint = $link->getConstraint();
if ($platformRequirementFilter->isIgnored($link->getTarget())) {
continue;
}
elseif ($platformRequirementFilter instanceof IgnoreListPlatformRequirementFilter) {
$constraint = $platformRequirementFilter->filterConstraint($link->getTarget(), $constraint, false);
}
$conflicts = $this->pool
->whatProvides($link->getTarget(), $constraint);
foreach ($conflicts as $conflict) {
// define the conflict rule for regular packages, for alias packages it's only needed if the name
// matches the conflict exactly, otherwise the name match is by provide/replace which means the
// package which this is an alias of will conflict anyway, so no need to create additional rules
if (!$conflict instanceof AliasPackage || $conflict->getName() === $link->getTarget()) {
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, $link));
}
}
}
}
foreach ($this->addedPackagesByNames as $name => $packages) {
if (\count($packages) > 1) {
$reason = Rule::RULE_PACKAGE_SAME_NAME;
$this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
}
}
}