Fix support for extracting stability flags in multi-constraints, fixes #4440
parent
507415e404
commit
82349bcb2a
|
@ -144,16 +144,33 @@ class RootPackageLoader extends ArrayLoader
|
|||
$stabilities = BasePackage::$stabilities;
|
||||
$minimumStability = $stabilities[$minimumStability];
|
||||
foreach ($requires as $reqName => $reqVersion) {
|
||||
// parse explicit stability flags to the most unstable
|
||||
if (preg_match('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $reqVersion, $match)) {
|
||||
$name = strtolower($reqName);
|
||||
$stability = $stabilities[VersionParser::normalizeStability($match[1])];
|
||||
$constraints = array();
|
||||
|
||||
if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
|
||||
continue;
|
||||
// extract all sub-constraints in case it is an OR/AND multi-constraint
|
||||
$orSplit = preg_split('{\s*\|\|?\s*}', trim($reqVersion));
|
||||
foreach ($orSplit as $constraint) {
|
||||
$andSplit = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraint);
|
||||
foreach ($andSplit as $constraint) {
|
||||
$constraints[] = $constraint;
|
||||
}
|
||||
$stabilityFlags[$name] = $stability;
|
||||
}
|
||||
|
||||
// parse explicit stability flags to the most unstable
|
||||
$match = false;
|
||||
foreach ($constraints as $constraint) {
|
||||
if (preg_match('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
|
||||
$name = strtolower($reqName);
|
||||
$stability = $stabilities[VersionParser::normalizeStability($match[1])];
|
||||
|
||||
if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
|
||||
continue;
|
||||
}
|
||||
$stabilityFlags[$name] = $stability;
|
||||
$match = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($match) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,8 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
'bar/baz' => '1.0.x-dev as 1.2.0',
|
||||
'qux/quux' => '1.0.*@rc',
|
||||
'zux/complex' => '~1.0,>=1.0.2@dev',
|
||||
'or/op' => '^2.0@dev || ^2.0@dev',
|
||||
'multi/lowest-wins' => '^2.0@rc || >=3.0@dev , ~3.5@alpha',
|
||||
),
|
||||
'minimum-stability' => 'alpha',
|
||||
));
|
||||
|
@ -51,6 +53,8 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase
|
|||
'bar/baz' => BasePackage::STABILITY_DEV,
|
||||
'qux/quux' => BasePackage::STABILITY_RC,
|
||||
'zux/complex' => BasePackage::STABILITY_DEV,
|
||||
'or/op' => BasePackage::STABILITY_DEV,
|
||||
'multi/lowest-wins' => BasePackage::STABILITY_DEV,
|
||||
), $package->getStabilityFlags());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue