1
0
Fork 0

Include pre-releases in >=2.3.0 comparison. Fixes #4080.

This is a change to the >=2.3.0 comparison. Without this change, such a
comparison will exclude pre-release versions.

The rationale is that this makes the comparison more consistent with
<2.3.0 (which excludes all pre-releases) and ~2.3.0 (which includes
pre-releases).
pull/4199/head
Sam Minnee 2015-06-30 11:21:49 +01:00
parent 5cd1b6d56f
commit 2cd698874f
2 changed files with 7 additions and 4 deletions

View File

@ -443,11 +443,13 @@ class VersionParser
if (!empty($stabilityModifier) && $this->parseStability($version) === 'stable') {
$version .= '-' . $stabilityModifier;
} elseif ('<' === $matches[1]) {
} elseif ('<' === $matches[1] || '>=' === $matches[1]) {
if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
if (substr($matches[2], 0, 4) !== 'dev-') {
$version .= '-dev';
}
}
}
return array(new VersionConstraint($matches[1] ?: '=', $version));
} catch (\Exception $e) {

View File

@ -244,13 +244,13 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
'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-dev')),
'less/eq than' => array('<=1.2.3', new VersionConstraint('<=', '1.2.3.0')),
'great/eq than' => array('>=1.2.3', new VersionConstraint('>=', '1.2.3.0')),
'great/eq than' => array('>=1.2.3', new VersionConstraint('>=', '1.2.3.0-dev')),
'equals' => array('=1.2.3', new VersionConstraint('=', '1.2.3.0')),
'double equals' => array('==1.2.3', new VersionConstraint('=', '1.2.3.0')),
'no op means eq' => array('1.2.3', new VersionConstraint('=', '1.2.3.0')),
'completes version' => array('=1.0', new VersionConstraint('=', '1.0.0.0')),
'shorthand beta' => array('1.2.3b5', new VersionConstraint('=', '1.2.3.0-beta5')),
'accepts spaces' => array('>= 1.2.3', new VersionConstraint('>=', '1.2.3.0')),
'accepts spaces' => array('>= 1.2.3', new VersionConstraint('>=', '1.2.3.0-dev')),
'accepts spaces/2' => array('< 1.2.3', new VersionConstraint('<', '1.2.3.0-dev')),
'accepts spaces/3' => array('> 1.2.3', new VersionConstraint('>', '1.2.3.0')),
'accepts master' => array('>=dev-master', new VersionConstraint('>=', '9999999-dev')),
@ -260,6 +260,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
'regression #935' => array('dev-CAPS', new VersionConstraint('=', 'dev-CAPS')),
'ignores aliases' => array('dev-master as 1.0.0', new VersionConstraint('=', '9999999-dev')),
'lesser than override' => array('<1.2.3.4-stable', new VersionConstraint('<', '1.2.3.4')),
'great/eq than override' => array('>=1.2.3.4-stable', new VersionConstraint('>=', '1.2.3.4')),
);
}