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

Breadcrumb

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

function Rule::getSourcePackage

@internal

File

vendor/composer/composer/src/Composer/DependencyResolver/Rule.php, line 200

Class

Rule
@author Nils Adermann <naderman@naderman.de> @author Ruben Gonzalez <rubenrua@gmail.com> @phpstan-type ReasonData Link|BasePackage|string|int|array{packageName: string, constraint: ConstraintInterface}|array{package: BasePackage}

Namespace

Composer\DependencyResolver

Code

public function getSourcePackage(Pool $pool) : BasePackage {
    $literals = $this->getLiterals();
    switch ($this->getReason()) {
        case self::RULE_PACKAGE_CONFLICT:
            $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
            $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
            $reasonData = $this->getReasonData();
            // swap literals if they are not in the right order with package2 being the conflicter
            if ($reasonData->getSource() === $package1->getName()) {
                [
                    $package2,
                    $package1,
                ] = [
                    $package1,
                    $package2,
                ];
            }
            return $package2;
        case self::RULE_PACKAGE_REQUIRES:
            $sourceLiteral = $literals[0];
            $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
            return $sourcePackage;
        default:
            throw new \LogicException('Not implemented');
    }
}

API Navigation

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