mirror of
https://github.com/composer/composer
synced 2025-05-10 17:12:51 +00:00
Minor improvements to VersionParser
This commit is contained in:
parent
bd45194292
commit
da6566b343
2 changed files with 5 additions and 3 deletions
|
@ -49,9 +49,9 @@ class VersionParser
|
||||||
// add version modifiers if a version was matched
|
// add version modifiers if a version was matched
|
||||||
if (isset($index)) {
|
if (isset($index)) {
|
||||||
if (!empty($matches[$index])) {
|
if (!empty($matches[$index])) {
|
||||||
$mod = array('p', 'pl', 'rc');
|
$mod = array('{^pl?$}', '{^rc$}');
|
||||||
$modNormalized = array('patch', 'patch', 'RC');
|
$modNormalized = array('patch', 'RC');
|
||||||
$version .= '-'.str_replace($mod, $modNormalized, strtolower($matches[$index]))
|
$version .= '-'.preg_replace($mod, $modNormalized, strtolower($matches[$index]))
|
||||||
. (!empty($matches[$index+1]) ? $matches[$index+1] : '');
|
. (!empty($matches[$index+1]) ? $matches[$index+1] : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
||||||
'parses state' => array('1.0.0RC1dev', '1.0.0.0-RC1-dev'),
|
'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'),
|
'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'),
|
'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('1.0-dev', '1.0.0.0-dev'),
|
||||||
'forces w.x.y.z' => array('0', '0.0.0.0'),
|
'forces w.x.y.z' => array('0', '0.0.0.0'),
|
||||||
'parses long' => array('10.4.13-beta', '10.4.13.0-beta'),
|
'parses long' => array('10.4.13-beta', '10.4.13.0-beta'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue