Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. RuleSetGenerator.php

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\DependencyResolver

Code

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));
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal