1
0
Fork 0

Infer stability flags for requirements that have an explicit version required of a lower stability

pull/592/head
Jordi Boggiano 2012-05-09 20:03:56 +02:00
parent fabf5c2f6d
commit a3018c43eb
1 changed files with 13 additions and 0 deletions

View File

@ -119,6 +119,7 @@ class RootPackageLoader extends ArrayLoader
{ {
$stabilities = BasePackage::$stabilities; $stabilities = BasePackage::$stabilities;
foreach ($requires as $reqName => $reqVersion) { foreach ($requires as $reqName => $reqVersion) {
// parse explicit stability flags
if (preg_match('{^[^,\s]*?@('.implode('|', $stabilities).')$}i', $reqVersion, $match)) { if (preg_match('{^[^,\s]*?@('.implode('|', $stabilities).')$}i', $reqVersion, $match)) {
$name = strtolower($reqName); $name = strtolower($reqName);
$stability = array_search(VersionParser::normalizeStability($match[1]), $stabilities); $stability = array_search(VersionParser::normalizeStability($match[1]), $stabilities);
@ -127,6 +128,18 @@ class RootPackageLoader extends ArrayLoader
continue; continue;
} }
$stabilityFlags[$name] = $stability; $stabilityFlags[$name] = $stability;
continue;
}
// infer flags for requirements that have an explicit -dev or -beta version specified for example
if (preg_match('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
$name = strtolower($reqName);
$stability = array_search($stabilityName, $stabilities);
if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
continue;
}
$stabilityFlags[$name] = $stability;
} }
} }