1
0
Fork 0

Minor improvements to VersionParser

pull/23/merge
Jordi Boggiano 2011-09-26 20:34:30 +02:00
parent bd45194292
commit da6566b343
2 changed files with 5 additions and 3 deletions

View File

@ -49,9 +49,9 @@ class VersionParser
// add version modifiers if a version was matched
if (isset($index)) {
if (!empty($matches[$index])) {
$mod = array('p', 'pl', 'rc');
$modNormalized = array('patch', 'patch', 'RC');
$version .= '-'.str_replace($mod, $modNormalized, strtolower($matches[$index]))
$mod = array('{^pl?$}', '{^rc$}');
$modNormalized = array('patch', 'RC');
$version .= '-'.preg_replace($mod, $modNormalized, strtolower($matches[$index]))
. (!empty($matches[$index+1]) ? $matches[$index+1] : '');
}

View File

@ -35,6 +35,8 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
'parses state' => array('1.0.0RC1dev', '1.0.0.0-RC1-dev'),
'CI parsing' => array('1.0.0-rC15-dev', '1.0.0.0-RC15-dev'),
'delimiters' => array('1.0.0.RC.15-dev', '1.0.0.0-RC15-dev'),
'RC uppercase' => array('1.0.0-rc1', '1.0.0.0-RC1'),
'patch replace' => array('1.0.0.pl3-dev', '1.0.0.0-patch3-dev'),
'forces w.x.y.z' => array('1.0-dev', '1.0.0.0-dev'),
'forces w.x.y.z' => array('0', '0.0.0.0'),
'parses long' => array('10.4.13-beta', '10.4.13.0-beta'),