Fix version parser regression, fixes #550
parent
68a1bc645b
commit
8654c43c62
|
@ -149,13 +149,12 @@ class VersionParser
|
|||
|
||||
private function parseConstraint($constraint)
|
||||
{
|
||||
$normalized = strtr($constraint, 'x', '*');
|
||||
if ('*' === $normalized || '*.*' === $normalized || '*.*.*' === $normalized || '*.*.*.*' === $normalized) {
|
||||
if (preg_match('{^[x*](\.[x*])*$}i', $constraint)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// match wildcard constraints
|
||||
if (preg_match('{^(\d+)(?:\.(\d+))?(?:\.(\d+))?\.\*$}', $normalized, $matches)) {
|
||||
if (preg_match('{^(\d+)(?:\.(\d+))?(?:\.(\d+))?\.[x*]$}', $constraint, $matches)) {
|
||||
if (isset($matches[3])) {
|
||||
$highVersion = $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.9999999';
|
||||
if ($matches[3] === '0') {
|
||||
|
@ -186,7 +185,7 @@ class VersionParser
|
|||
}
|
||||
|
||||
// match operators constraints
|
||||
if (preg_match('{^(>=?|<=?|==?)?\s*(.*)}', $normalized, $matches)) {
|
||||
if (preg_match('{^(>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
|
||||
try {
|
||||
$version = $this->normalize($matches[2]);
|
||||
return array(new VersionConstraint($matches[1] ?: '=', $version));
|
||||
|
|
|
@ -117,6 +117,10 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
public function simpleConstraints()
|
||||
{
|
||||
return array(
|
||||
'match any' => array('*', new MultiConstraint(array())),
|
||||
'match any/2' => array('*.*', new MultiConstraint(array())),
|
||||
'match any/3' => array('*.x.*', new MultiConstraint(array())),
|
||||
'match any/4' => array('x.x.x.*', new MultiConstraint(array())),
|
||||
'greater than' => array('>1.0.0', new VersionConstraint('>', '1.0.0.0')),
|
||||
'lesser than' => array('<1.2.3.4', new VersionConstraint('<', '1.2.3.4')),
|
||||
'less/eq than' => array('<=1.2.3', new VersionConstraint('<=', '1.2.3.0')),
|
||||
|
@ -129,6 +133,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
'accepts master' => array('>=dev-master', new VersionConstraint('>=', '9999999-dev')),
|
||||
'accepts master/2' => array('dev-master', new VersionConstraint('=', '9999999-dev')),
|
||||
'accepts arbitrary' => array('dev-feature-a', new VersionConstraint('=', 'dev-feature-a')),
|
||||
'regression #550' => array('dev-some-fix', new VersionConstraint('=', 'dev-some-fix')),
|
||||
'ignores aliases' => array('dev-master as 1.0.0', new VersionConstraint('=', '1.0.0.0')),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue