public function Constraint::matchSpecific in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/composer/semver/src/Constraint/Constraint.php \Composer\Semver\Constraint\Constraint::matchSpecific()
Parameters
Constraint $provider:
bool $compareBranches:
Return value
bool
File
- vendor/
composer/ semver/ src/ Constraint/ Constraint.php, line 136
Class
- Constraint
- Defines a constraint.
Namespace
Composer\Semver\ConstraintCode
public function matchSpecific(Constraint $provider, $compareBranches = false) {
$noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
$providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
$isEqualOp = self::OP_EQ === $this->operator;
$isNonEqualOp = self::OP_NE === $this->operator;
$isProviderEqualOp = self::OP_EQ === $provider->operator;
$isProviderNonEqualOp = self::OP_NE === $provider->operator;
// '!=' operator is match when other operator is not '==' operator or version is not match
// these kinds of comparisons always have a solution
if ($isNonEqualOp || $isProviderNonEqualOp) {
return !$isEqualOp && !$isProviderEqualOp || $this
->versionCompare($provider->version, $this->version, '!=', $compareBranches);
}
// an example for the condition is <= 2.0 & < 1.0
// these kinds of comparisons always have a solution
if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
return true;
}
if ($this
->versionCompare($provider->version, $this->version, self::$transOpInt[$this->operator], $compareBranches)) {
// special case, e.g. require >= 1.0 and provide < 1.0
// 1.0 >= 1.0 but 1.0 is outside of the provided interval
if ($provider->version === $this->version && self::$transOpInt[$provider->operator] === $providerNoEqualOp && self::$transOpInt[$this->operator] !== $noEqualOp) {
return false;
}
return true;
}
return false;
}