From 75d3d57117337c93a0b0ca3f3a1b9c8b54cd4fef Mon Sep 17 00:00:00 2001 From: Alexey Prilipko Date: Mon, 9 Jul 2012 08:47:40 +1100 Subject: [PATCH] Version parser stability regexp update --- src/Composer/Package/Version/VersionParser.php | 14 +++++++++++--- .../Test/Package/Version/VersionParserTest.php | 3 +++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Composer/Package/Version/VersionParser.php b/src/Composer/Package/Version/VersionParser.php index 058ad1ee8..2523acffd 100644 --- a/src/Composer/Package/Version/VersionParser.php +++ b/src/Composer/Package/Version/VersionParser.php @@ -24,7 +24,7 @@ use Composer\Package\LinkConstraint\VersionConstraint; */ class VersionParser { - private static $modifierRegex = '[.-]?(?:(beta|RC|alpha|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?'; + private static $modifierRegex = '[._-]?(?:(beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?'; /** * Returns the stability of a version @@ -45,8 +45,16 @@ class VersionParser return 'dev'; } - if (!empty($match[1]) && ($match[1] === 'beta' || $match[1] === 'alpha' || $match[1] === 'RC')) { - return $match[1]; + if (!empty($match[1])) { + if ('beta' === $match[1] || 'b' === $match[1]) { + return 'beta'; + } + if ('alpha' === $match[1] || 'a' === $match[1]) { + return 'alpha'; + } + if ('RC' === $match[1]) { + return 'RC'; + } } return 'stable'; diff --git a/tests/Composer/Test/Package/Version/VersionParserTest.php b/tests/Composer/Test/Package/Version/VersionParserTest.php index ec99b3b27..272f37571 100644 --- a/tests/Composer/Test/Package/Version/VersionParserTest.php +++ b/tests/Composer/Test/Package/Version/VersionParserTest.php @@ -238,6 +238,9 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase array('stable', '3.1.2-patch'), array('alpha', '3.1.2-alpha5'), array('beta', '3.1.2-beta'), + array('beta', '2.0b1'), + array('alpha', '1.2.0a1'), + array('alpha', '1.2_a1'), ); } }