Allow .x in version constraints as alias for .*

main
Jordi Boggiano 12 years ago
parent 96c9bf80cc
commit f604ca5762

@ -149,12 +149,13 @@ class VersionParser
private function parseConstraint($constraint)
{
if ('*' === $constraint || '*.*' === $constraint || '*.*.*' === $constraint || '*.*.*.*' === $constraint) {
$normalized = strtr($constraint, 'x', '*');
if ('*' === $normalized || '*.*' === $normalized || '*.*.*' === $normalized || '*.*.*.*' === $normalized) {
return array();
}
// match wildcard constraints
if (preg_match('{^(\d+)(?:\.(\d+))?(?:\.(\d+))?\.\*$}', $constraint, $matches)) {
if (preg_match('{^(\d+)(?:\.(\d+))?(?:\.(\d+))?\.\*$}', $normalized, $matches)) {
if (isset($matches[3])) {
$highVersion = $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.9999999';
if ($matches[3] === '0') {
@ -185,7 +186,7 @@ class VersionParser
}
// match operators constraints
if (preg_match('{^(>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
if (preg_match('{^(>=?|<=?|==?)?\s*(.*)}', $normalized, $matches)) {
try {
$version = $this->normalize($matches[2]);
return array(new VersionConstraint($matches[1] ?: '=', $version));

@ -154,8 +154,8 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
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.*', new VersionConstraint('>', '2.1.9999999.9999999'), new VersionConstraint('<', '2.2.9999999.9999999')),
array('2.10.*', new VersionConstraint('>', '2.9.9999999.9999999'), new VersionConstraint('<', '2.10.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('0.*', null, new VersionConstraint('<', '0.9999999.9999999.9999999')),
);

Loading…
Cancel
Save