Fixed lower bound of tilde and wildcard matches.
The lower bound of ~1.2 and 1.2.* style version requirements now uses >= 1.2.0.0-dev instead of > 1.1.9999999.9999999. This is more straightforward to read, and behaves equivalently.pull/1881/head
parent
be9aae5bab
commit
95b4348afa
|
@ -297,16 +297,9 @@ class VersionParser
|
|||
$stabilitySuffix .= '-dev';
|
||||
}
|
||||
|
||||
// If we don't have a stability suffix, the lower bound is "> the previous version"
|
||||
if ($stabilitySuffix == '') {
|
||||
$lowVersion = $this->manipulateVersionString($matches, $position, -1, '9999999');
|
||||
$lowerBound = new VersionConstraint('>', $lowVersion);
|
||||
|
||||
// If we have a stability suffix, then our comparison is ">= this version"
|
||||
} else {
|
||||
$lowVersion = $this->manipulateVersionString($matches, $position, 0);
|
||||
$lowerBound = new VersionConstraint('>=', $lowVersion . $stabilitySuffix);
|
||||
}
|
||||
if(!$stabilitySuffix) $stabilitySuffix = "-dev";
|
||||
$lowVersion = $this->manipulateVersionString($matches, $position, 0) . $stabilitySuffix;
|
||||
$lowerBound = new VersionConstraint('>=', $lowVersion);
|
||||
|
||||
// For upper bound, we increment the position of one more significance,
|
||||
// but highPosition = 0 would be illegal
|
||||
|
@ -330,14 +323,14 @@ class VersionParser
|
|||
$position = 1;
|
||||
}
|
||||
|
||||
$lowVersion = $this->manipulateVersionString($matches, $position) . "-dev";
|
||||
$highVersion = $this->manipulateVersionString($matches, $position, 0, '9999999');
|
||||
$lowVersion = $this->manipulateVersionString($matches, $position, -1, '9999999');
|
||||
|
||||
if($lowVersion === null) {
|
||||
if($lowVersion === "0.0.0.0-dev") {
|
||||
return array(new VersionConstraint('<', $highVersion));
|
||||
} else {
|
||||
return array(
|
||||
new VersionConstraint('>', $lowVersion),
|
||||
new VersionConstraint('>=', $lowVersion),
|
||||
new VersionConstraint('<', $highVersion),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -237,12 +237,12 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
public function wildcardConstraints()
|
||||
{
|
||||
return array(
|
||||
array('2.*', new VersionConstraint('>', '1.9999999.9999999.9999999'), new VersionConstraint('<', '2.9999999.9999999.9999999')),
|
||||
array('20.*', new VersionConstraint('>', '19.9999999.9999999.9999999'), new VersionConstraint('<', '20.9999999.9999999.9999999')),
|
||||
array('2.0.*', new VersionConstraint('>', '1.9999999.9999999.9999999'), new VersionConstraint('<', '2.0.9999999.9999999')),
|
||||
array('2.2.x', new VersionConstraint('>', '2.1.9999999.9999999'), new VersionConstraint('<', '2.2.9999999.9999999')),
|
||||
array('2.10.x', new VersionConstraint('>', '2.9.9999999.9999999'), new VersionConstraint('<', '2.10.9999999.9999999')),
|
||||
array('2.1.3.*', new VersionConstraint('>', '2.1.2.9999999'), new VersionConstraint('<', '2.1.3.9999999')),
|
||||
array('2.*', new VersionConstraint('>=', '2.0.0.0-dev'), new VersionConstraint('<', '2.9999999.9999999.9999999')),
|
||||
array('20.*', new VersionConstraint('>=', '20.0.0.0-dev'), new VersionConstraint('<', '20.9999999.9999999.9999999')),
|
||||
array('2.0.*', new VersionConstraint('>=', '2.0.0.0-dev'), new VersionConstraint('<', '2.0.9999999.9999999')),
|
||||
array('2.2.x', new VersionConstraint('>=', '2.2.0.0-dev'), new VersionConstraint('<', '2.2.9999999.9999999')),
|
||||
array('2.10.x', new VersionConstraint('>=', '2.10.0.0-dev'), new VersionConstraint('<', '2.10.9999999.9999999')),
|
||||
array('2.1.3.*', new VersionConstraint('>=', '2.1.3.0-dev'), new VersionConstraint('<', '2.1.3.9999999')),
|
||||
array('0.*', null, new VersionConstraint('<', '0.9999999.9999999.9999999')),
|
||||
);
|
||||
}
|
||||
|
@ -265,12 +265,12 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
public function tildeConstraints()
|
||||
{
|
||||
return array(
|
||||
array('~1', new VersionConstraint('>', '0.9999999.9999999.9999999'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
array('~1.0', new VersionConstraint('>', '0.9999999.9999999.9999999'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
array('~1.0.0', new VersionConstraint('>', '0.9999999.9999999.9999999'), new VersionConstraint('<', '1.1.0.0-dev')),
|
||||
array('~1.2', new VersionConstraint('>', '1.1.9999999.9999999'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
array('~1.2.3', new VersionConstraint('>', '1.2.2.9999999'), new VersionConstraint('<', '1.3.0.0-dev')),
|
||||
array('~1.2.3.4', new VersionConstraint('>', '1.2.3.3'), new VersionConstraint('<', '1.2.4.0-dev')),
|
||||
array('~1', new VersionConstraint('>=', '1.0.0.0-dev'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
array('~1.0', new VersionConstraint('>=', '1.0.0.0-dev'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
array('~1.0.0', new VersionConstraint('>=', '1.0.0.0-dev'), new VersionConstraint('<', '1.1.0.0-dev')),
|
||||
array('~1.2', new VersionConstraint('>=', '1.2.0.0-dev'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
array('~1.2.3', new VersionConstraint('>=', '1.2.3.0-dev'), new VersionConstraint('<', '1.3.0.0-dev')),
|
||||
array('~1.2.3.4', new VersionConstraint('>=', '1.2.3.4-dev'), new VersionConstraint('<', '1.2.4.0-dev')),
|
||||
array('~1.2-beta',new VersionConstraint('>=', '1.2.0.0-beta'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
array('~1.2-b2', new VersionConstraint('>=', '1.2.0.0-beta2'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
array('~1.2-BETA2', new VersionConstraint('>=', '1.2.0.0-beta2'), new VersionConstraint('<', '2.0.0.0-dev')),
|
||||
|
|
Loading…
Reference in New Issue