class GenericRule
@author Nils Adermann <naderman@naderman.de>
Hierarchy
- class \Composer\DependencyResolver\Rule
- class \Composer\DependencyResolver\GenericRule extends \Composer\DependencyResolver\Rule
Expanded class hierarchy of GenericRule
File
-
vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ GenericRule.php, line 18
Namespace
Composer\DependencyResolverView source
class GenericRule extends Rule {
/** @var list<int> */
protected $literals;
/**
* @param list<int> $literals
*/
public function __construct(array $literals, $reason, $reasonData) {
parent::__construct($reason, $reasonData);
// sort all packages ascending by id
sort($literals);
$this->literals = $literals;
}
/**
* @return list<int>
*/
public function getLiterals() : array {
return $this->literals;
}
/**
* @inheritDoc
*/
public function getHash() {
$data = unpack('ihash', (string) hash(\PHP_VERSION_ID > 80100 ? 'xxh3' : 'sha1', implode(',', $this->literals), true));
if (false === $data) {
throw new \RuntimeException('Failed unpacking: ' . implode(', ', $this->literals));
}
return $data['hash'];
}
/**
* Checks if this rule is equal to another one
*
* Ignores whether either of the rules is disabled.
*
* @param Rule $rule The rule to check against
* @return bool Whether the rules are equal
*/
public function equals(Rule $rule) : bool {
return $this->literals === $rule->getLiterals();
}
public function isAssertion() : bool {
return 1 === \count($this->literals);
}
/**
* Formats a rule as a string of the format (Literal1|Literal2|...)
*/
public function __toString() : string {
$result = $this->isDisabled() ? 'disabled(' : '(';
foreach ($this->literals as $i => $literal) {
if ($i !== 0) {
$result .= '|';
}
$result .= $literal;
}
$result .= ')';
return $result;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
GenericRule::$literals | protected | property | @var list<int> | ||
GenericRule::equals | public | function | Checks if this rule is equal to another one | Overrides Rule::equals | |
GenericRule::getHash | public | function | @inheritDoc | Overrides Rule::getHash | |
GenericRule::getLiterals | public | function | Overrides Rule::getLiterals | ||
GenericRule::isAssertion | public | function | Overrides Rule::isAssertion | ||
GenericRule::__construct | public | function | Overrides Rule::__construct | ||
GenericRule::__toString | public | function | Formats a rule as a string of the format (Literal1|Literal2|...) | Overrides Rule::__toString | |
Rule::$bitfield | protected | property | @var int | ||
Rule::$reasonData | protected | property | @phpstan-var ReasonData | ||
Rule::$request | protected | property | @var Request | ||
Rule::BITFIELD_DISABLED | private | constant | |||
Rule::BITFIELD_REASON | private | constant | |||
Rule::BITFIELD_TYPE | private | constant | |||
Rule::deduplicateDefaultBranchAlias | private | function | |||
Rule::disable | public | function | 1 | ||
Rule::enable | public | function | |||
Rule::formatPackagesUnique | protected | function | |||
Rule::getPrettyString | public | function | |||
Rule::getReason | public | function | |||
Rule::getReasonData | public | function | @phpstan-return ReasonData | ||
Rule::getRequiredPackage | public | function | |||
Rule::getSourcePackage | public | function | @internal | ||
Rule::getType | public | function | |||
Rule::isCausedByLock | public | function | |||
Rule::isDisabled | public | function | |||
Rule::isEnabled | public | function | |||
Rule::RULE_FIXED | public | constant | |||
Rule::RULE_LEARNED | public | constant | |||
Rule::RULE_PACKAGE_ALIAS | public | constant | |||
Rule::RULE_PACKAGE_CONFLICT | public | constant | |||
Rule::RULE_PACKAGE_INVERSE_ALIAS | public | constant | |||
Rule::RULE_PACKAGE_REQUIRES | public | constant | |||
Rule::RULE_PACKAGE_SAME_NAME | public | constant | |||
Rule::RULE_ROOT_REQUIRE | public | constant | |||
Rule::setType | public | function |