diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index f14f09622..a141bdc43 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -360,7 +360,7 @@ class VersionParser if (!empty($stabilityModifier) && $this->parseStability($version) === 'stable') { $version .= '-' . $stabilityModifier; } elseif ('<' === $matches[1]) { - if (!preg_match('/-stable$/', strtolower($matches[2]))) { + if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) { $version .= '-dev'; } } diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php index 25c2b9898..c8136f6f3 100644 --- a/tests/Composer/Test/Package/Version/VersionParserTest.php +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -300,6 +300,20 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase $this->assertSame((string) $multi, (string) $parser->parseConstraints('>2.0,<=3.0')); } + public function testParseConstraintsMultiWithStabilitySuffix() + { + $parser = new VersionParser; + $first = new VersionConstraint('>=', '1.1.0.0-alpha4'); + $second = new VersionConstraint('<', '1.2.9999999.9999999-dev'); + $multi = new MultiConstraint(array($first, $second)); + $this->assertSame((string) $multi, (string) $parser->parseConstraints('>=1.1.0-alpha4,<1.2.x-dev')); + + $first = new VersionConstraint('>=', '1.1.0.0-alpha4'); + $second = new VersionConstraint('<', '1.2.0.0-beta2'); + $multi = new MultiConstraint(array($first, $second)); + $this->assertSame((string) $multi, (string) $parser->parseConstraints('>=1.1.0-alpha4,<1.2-beta2')); + } + public function testParseConstraintsMultiDisjunctiveHasPrioOverConjuctive() { $parser = new VersionParser;