Refactor wildcard matching to use manipulateVersionString
parent
34a21516c8
commit
b25457a8c1
|
@ -317,33 +317,21 @@ class VersionParser
|
||||||
|
|
||||||
// match wildcard constraints
|
// match wildcard constraints
|
||||||
if (preg_match('{^(\d+)(?:\.(\d+))?(?:\.(\d+))?\.[x*]$}', $constraint, $matches)) {
|
if (preg_match('{^(\d+)(?:\.(\d+))?(?:\.(\d+))?\.[x*]$}', $constraint, $matches)) {
|
||||||
if (isset($matches[3])) {
|
if (isset($matches[3]) && '' !== $matches[3]) $position = 3;
|
||||||
$highVersion = $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.9999999';
|
else if (isset($matches[2]) && '' !== $matches[2]) $position = 2;
|
||||||
if ($matches[3] === '0') {
|
else $position = 1;
|
||||||
$lowVersion = $matches[1] . '.' . ($matches[2] - 1) . '.9999999.9999999';
|
|
||||||
} else {
|
|
||||||
$lowVersion = $matches[1] . '.' . $matches[2] . '.' . ($matches[3] - 1). '.9999999';
|
|
||||||
}
|
|
||||||
} elseif (isset($matches[2])) {
|
|
||||||
$highVersion = $matches[1] . '.' . $matches[2] . '.9999999.9999999';
|
|
||||||
if ($matches[2] === '0') {
|
|
||||||
$lowVersion = ($matches[1] - 1) . '.9999999.9999999.9999999';
|
|
||||||
} else {
|
|
||||||
$lowVersion = $matches[1] . '.' . ($matches[2] - 1) . '.9999999.9999999';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$highVersion = $matches[1] . '.9999999.9999999.9999999';
|
|
||||||
if ($matches[1] === '0') {
|
|
||||||
return array(new VersionConstraint('<', $highVersion));
|
|
||||||
} else {
|
|
||||||
$lowVersion = ($matches[1] - 1) . '.9999999.9999999.9999999';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return array(
|
$highVersion = $this->manipulateVersionString($matches,$position,0,'9999999');
|
||||||
new VersionConstraint('>', $lowVersion),
|
$lowVersion = $this->manipulateVersionString($matches,$position,-1,'9999999');
|
||||||
new VersionConstraint('<', $highVersion),
|
|
||||||
);
|
if($lowVersion === null) {
|
||||||
|
return array(new VersionConstraint('<', $highVersion));
|
||||||
|
} else {
|
||||||
|
return array(
|
||||||
|
new VersionConstraint('>', $lowVersion),
|
||||||
|
new VersionConstraint('<', $highVersion),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// match operators constraints
|
// match operators constraints
|
||||||
|
@ -392,6 +380,9 @@ class VersionParser
|
||||||
if($matches[$i] < 0) {
|
if($matches[$i] < 0) {
|
||||||
$matches[$i] = $pad;
|
$matches[$i] = $pad;
|
||||||
$position--;
|
$position--;
|
||||||
|
|
||||||
|
// Return null on a carry overflow
|
||||||
|
if($i == 1) return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue