فهرست منبع

Version parser stability regexp update

Alexey Prilipko 13 سال پیش
والد
کامیت
75d3d57117
2فایلهای تغییر یافته به همراه14 افزوده شده و 3 حذف شده
  1. 11 3
      src/Composer/Package/Version/VersionParser.php
  2. 3 0
      tests/Composer/Test/Package/Version/VersionParserTest.php

+ 11 - 3
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';

+ 3 - 0
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'),
         );
     }
 }