Formatting updates for PSR-2 compliance.
parent
b25457a8c1
commit
be9aae5bab
|
@ -277,10 +277,15 @@ class VersionParser
|
||||||
if (preg_match('{^~(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?'.self::$modifierRegex.'?$}i', $constraint, $matches)) {
|
if (preg_match('{^~(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:\.(\d+))?'.self::$modifierRegex.'?$}i', $constraint, $matches)) {
|
||||||
|
|
||||||
// Work out which position in the version we are operating at
|
// Work out which position in the version we are operating at
|
||||||
if (isset($matches[4]) && '' !== $matches[4]) $position = 4;
|
if (isset($matches[4]) && '' !== $matches[4]) {
|
||||||
else if (isset($matches[3]) && '' !== $matches[3]) $position = 3;
|
$position = 4;
|
||||||
else if (isset($matches[2]) && '' !== $matches[2]) $position = 2;
|
} elseif (isset($matches[3]) && '' !== $matches[3]) {
|
||||||
else $position = 1;
|
$position = 3;
|
||||||
|
} elseif (isset($matches[2]) && '' !== $matches[2]) {
|
||||||
|
$position = 2;
|
||||||
|
} else {
|
||||||
|
$position = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate the stability suffix
|
// Calculate the stability suffix
|
||||||
$stabilitySuffix = '';
|
$stabilitySuffix = '';
|
||||||
|
@ -294,19 +299,19 @@ class VersionParser
|
||||||
|
|
||||||
// If we don't have a stability suffix, the lower bound is "> the previous version"
|
// If we don't have a stability suffix, the lower bound is "> the previous version"
|
||||||
if ($stabilitySuffix == '') {
|
if ($stabilitySuffix == '') {
|
||||||
$lowVersion = $this->manipulateVersionString($matches, $position,-1,'9999999');
|
$lowVersion = $this->manipulateVersionString($matches, $position, -1, '9999999');
|
||||||
$lowerBound = new VersionConstraint('>', $lowVersion);
|
$lowerBound = new VersionConstraint('>', $lowVersion);
|
||||||
|
|
||||||
// If we have a stability suffix, then our comparison is ">= this version"
|
// If we have a stability suffix, then our comparison is ">= this version"
|
||||||
} else {
|
} else {
|
||||||
$lowVersion = $this->manipulateVersionString($matches,$position,0);
|
$lowVersion = $this->manipulateVersionString($matches, $position, 0);
|
||||||
$lowerBound = new VersionConstraint('>=', $lowVersion . $stabilitySuffix);
|
$lowerBound = new VersionConstraint('>=', $lowVersion . $stabilitySuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// For upper bound, we increment the position of one more significance,
|
// For upper bound, we increment the position of one more significance,
|
||||||
// but highPosition = 0 would be illegal
|
// but highPosition = 0 would be illegal
|
||||||
$highPosition = max(1,$position-1);
|
$highPosition = max(1, $position - 1);
|
||||||
$highVersion = $this->manipulateVersionString($matches,$highPosition,1).'-dev';
|
$highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
|
||||||
$upperBound = new VersionConstraint('<', $highVersion);
|
$upperBound = new VersionConstraint('<', $highVersion);
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
@ -317,12 +322,16 @@ 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]) && '' !== $matches[3]) $position = 3;
|
if (isset($matches[3]) && '' !== $matches[3]) {
|
||||||
else if (isset($matches[2]) && '' !== $matches[2]) $position = 2;
|
$position = 3;
|
||||||
else $position = 1;
|
} elseif (isset($matches[2]) && '' !== $matches[2]) {
|
||||||
|
$position = 2;
|
||||||
|
} else {
|
||||||
|
$position = 1;
|
||||||
|
}
|
||||||
|
|
||||||
$highVersion = $this->manipulateVersionString($matches,$position,0,'9999999');
|
$highVersion = $this->manipulateVersionString($matches, $position, 0, '9999999');
|
||||||
$lowVersion = $this->manipulateVersionString($matches,$position,-1,'9999999');
|
$lowVersion = $this->manipulateVersionString($matches, $position, -1, '9999999');
|
||||||
|
|
||||||
if($lowVersion === null) {
|
if($lowVersion === null) {
|
||||||
return array(new VersionConstraint('<', $highVersion));
|
return array(new VersionConstraint('<', $highVersion));
|
||||||
|
@ -353,7 +362,7 @@ class VersionParser
|
||||||
|
|
||||||
$message = 'Could not parse version constraint '.$constraint;
|
$message = 'Could not parse version constraint '.$constraint;
|
||||||
if (isset($e)) {
|
if (isset($e)) {
|
||||||
$message .= ': '.$e->getMessage();
|
$message .= ': '. $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \UnexpectedValueException($message);
|
throw new \UnexpectedValueException($message);
|
||||||
|
|
Loading…
Reference in New Issue