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