Allow parsing of stability modifiers combined with multi-constraints
parent
b3077bc4bc
commit
62bb5b339b
|
@ -234,6 +234,13 @@ class VersionParser
|
|||
|
||||
private function parseConstraint($constraint)
|
||||
{
|
||||
if (preg_match('{^([^,\s]+?)@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $constraint, $match)) {
|
||||
$constraint = $match[1];
|
||||
if ($match[2] !== 'stable') {
|
||||
$stabilityModifier = $match[2];
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('{^[x*](\.[x*])*$}i', $constraint)) {
|
||||
return array();
|
||||
}
|
||||
|
@ -274,6 +281,10 @@ class VersionParser
|
|||
try {
|
||||
$version = $this->normalize($matches[2]);
|
||||
|
||||
if (!empty($stabilityModifier) && $this->parseStability($version) === 'stable') {
|
||||
$version .= '-' . $stabilityModifier;
|
||||
}
|
||||
|
||||
return array(new VersionConstraint($matches[1] ?: '=', $version));
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
|
|
|
@ -249,6 +249,15 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertSame((string) $multi, (string) $parser->parseConstraints('>2.0,<=3.0'));
|
||||
}
|
||||
|
||||
public function testParseConstraintsMultiWithStabilities()
|
||||
{
|
||||
$parser = new VersionParser;
|
||||
$first = new VersionConstraint('>', '2.0.0.0');
|
||||
$second = new VersionConstraint('<=', '3.0.0.0-dev');
|
||||
$multi = new MultiConstraint(array($first, $second));
|
||||
$this->assertSame((string) $multi, (string) $parser->parseConstraints('>2.0@stable,<=3.0@dev'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider failingConstraints
|
||||
* @expectedException UnexpectedValueException
|
||||
|
|
Loading…
Reference in New Issue