1
0
Fork 0

Don't use BasePackage::$stabilities in VersionParser

Working towards #3545.

This adds VersionParser::$stabilities, which is an array of the
supported stability levels. This adds a little bit of duplication,
however we were already hardcoding the various stabilities in regular
expressions and functions like parseStability().
pull/4213/head
Kunal Mehta 2015-07-03 17:54:30 -07:00
parent 2438105e11
commit 0ad9e98a59
1 changed files with 6 additions and 3 deletions

View File

@ -12,7 +12,6 @@
namespace Composer\Package\Version;
use Composer\Package\BasePackage;
use Composer\Package\PackageInterface;
use Composer\Package\Link;
use Composer\Package\LinkConstraint\EmptyConstraint;
@ -28,6 +27,10 @@ class VersionParser
{
private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?';
private static $stabilities = array(
'stable', 'RC', 'beta', 'alpha', 'dev',
);
/**
* Returns the stability of a version
*
@ -241,7 +244,7 @@ class VersionParser
{
$prettyConstraint = $constraints;
if (preg_match('{^([^,\s]*?)@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $constraints, $match)) {
if (preg_match('{^([^,\s]*?)@('.implode('|', self::$stabilities).')$}i', $constraints, $match)) {
$constraints = empty($match[1]) ? '*' : $match[1];
}
@ -284,7 +287,7 @@ class VersionParser
private function parseConstraint($constraint)
{
if (preg_match('{^([^,\s]+?)@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $constraint, $match)) {
if (preg_match('{^([^,\s]+?)@('.implode('|', self::$stabilities).')$}i', $constraint, $match)) {
$constraint = $match[1];
if ($match[2] !== 'stable') {
$stabilityModifier = $match[2];