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

Breadcrumb

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

function RuleSetGenerator::createRequireRule

Creates a new rule for the requirements of a package

This rule is of the form (-A|B|C), where B and C are the providers of one requirement of the package A.

@phpstan-param ReasonData $reasonData

Parameters

BasePackage $package The package with a requirement:

BasePackage[] $providers The providers of the requirement:

Rule::RULE_* $reason A RULE_* constant describing the reason for generating this rule:

mixed $reasonData Any data, e.g. the requirement name, that goes with the reason:

Return value

Rule|null The generated rule or null if tautological

1 call to RuleSetGenerator::createRequireRule()
RuleSetGenerator::addRulesForPackage in vendor/composer/composer/src/Composer/DependencyResolver/RuleSetGenerator.php

File

vendor/composer/composer/src/Composer/DependencyResolver/RuleSetGenerator.php, line 59

Class

RuleSetGenerator
@author Nils Adermann <naderman@naderman.de> @phpstan-import-type ReasonData from Rule

Namespace

Composer\DependencyResolver

Code

protected function createRequireRule(BasePackage $package, array $providers, $reason, $reasonData) : ?Rule {
    $literals = [
        -$package->id,
    ];
    foreach ($providers as $provider) {
        // self fulfilling rule?
        if ($provider === $package) {
            return null;
        }
        $literals[] = $provider->id;
    }
    return new GenericRule($literals, $reason, $reasonData);
}

API Navigation

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