diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index 76ae63488..f0c25daba 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/src/Composer/Package/Loader/RootPackageLoader.php @@ -201,16 +201,18 @@ class RootPackageLoader extends ArrayLoader continue; } - // infer flags for requirements that have an explicit -dev or -beta version specified but only - // for those that are more unstable than the minimumStability or existing flags - $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion); - if (preg_match('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) { - $name = strtolower($reqName); - $stability = $stabilities[$stabilityName]; - if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) { - continue; + foreach ($constraints as $constraint) { + // infer flags for requirements that have an explicit -dev or -beta version specified but only + // for those that are more unstable than the minimumStability or existing flags + $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $constraint); + if (preg_match('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) { + $name = strtolower($reqName); + $stability = $stabilities[$stabilityName]; + if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) { + continue; + } + $stabilityFlags[$name] = $stability; } - $stabilityFlags[$name] = $stability; } } diff --git a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php index 0b311041e..951645971 100644 --- a/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/RootPackageLoaderTest.php @@ -44,6 +44,8 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase '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', + 'or/op/without-flags' => 'dev-master || 2.0 , ~3.5-alpha', + 'or/op/without-flags2' => '3.0-beta || 2.0 , ~3.5-alpha', ), 'minimum-stability' => 'alpha', )); @@ -55,6 +57,8 @@ class RootPackageLoaderTest extends \PHPUnit_Framework_TestCase 'zux/complex' => BasePackage::STABILITY_DEV, 'or/op' => BasePackage::STABILITY_DEV, 'multi/lowest-wins' => BasePackage::STABILITY_DEV, + 'or/op/without-flags' => BasePackage::STABILITY_DEV, + 'or/op/without-flags2' => BasePackage::STABILITY_ALPHA, ), $package->getStabilityFlags()); }