public function Constraint::versionCompare in Automatic Updates 7
Parameters
string $a:
string $b:
string $operator:
bool $compareBranches:
Return value
bool
Throws
\InvalidArgumentException if invalid operator is given.
1 call to Constraint::versionCompare()
- Constraint::matchSpecific in vendor/
composer/ semver/ src/ Constraint/ Constraint.php
File
- vendor/
composer/ semver/ src/ Constraint/ Constraint.php, line 143
Class
- Constraint
- Defines a constraint.
Namespace
Composer\Semver\ConstraintCode
public function versionCompare($a, $b, $operator, $compareBranches = false) {
if (!isset(self::$transOpStr[$operator])) {
throw new \InvalidArgumentException(sprintf('Invalid operator "%s" given, expected one of: %s', $operator, implode(', ', self::getSupportedOperators())));
}
$aIsBranch = 'dev-' === substr($a, 0, 4);
$bIsBranch = 'dev-' === substr($b, 0, 4);
if ($aIsBranch && $bIsBranch) {
return $operator === '==' && $a === $b;
}
// when branches are not comparable, we make sure dev branches never match anything
if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
return false;
}
return version_compare($a, $b, $operator);
}