From 029f7093009f621bd20aef98c7bfc61631f18cf1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 7 Dec 2014 17:46:04 +0000 Subject: [PATCH] Fix parsing stability suffixes in multi constraints, fixes #1732 --- src/Composer/Package/Version/VersionParser.php | 2 +- .../Test/Package/Version/VersionParserTest.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) 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;