diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index 84d329ba5..7386b915a 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -16,6 +16,7 @@ use Composer\Composer; use Composer\DependencyResolver\Request; use Composer\Installer; use Composer\IO\IOInterface; +use Composer\Package\Loader\RootPackageLoader; use Composer\Plugin\CommandEvent; use Composer\Plugin\PluginEvents; use Composer\Package\Version\VersionParser; @@ -139,8 +140,9 @@ EOT } } - $rootRequires = $composer->getPackage()->getRequires(); - $rootDevRequires = $composer->getPackage()->getDevRequires(); + $rootPackage = $composer->getPackage(); + $rootRequires = $rootPackage->getRequires(); + $rootDevRequires = $rootPackage->getDevRequires(); foreach ($reqs as $package => $constraint) { if (isset($rootRequires[$package])) { $rootRequires[$package] = $this->appendConstraintToLink($rootRequires[$package], $constraint); @@ -150,8 +152,10 @@ EOT throw new \UnexpectedValueException('Only root package requirements can receive temporary constraints and '.$package.' is not one'); } } - $composer->getPackage()->setRequires($rootRequires); - $composer->getPackage()->setDevRequires($rootDevRequires); + $rootPackage->setRequires($rootRequires); + $rootPackage->setDevRequires($rootDevRequires); + $rootPackage->setReferences(RootPackageLoader::extractReferences($reqs, $rootPackage->getReferences())); + $rootPackage->setStabilityFlags(RootPackageLoader::extractStabilityFlags($reqs, $rootPackage->getMinimumStability(), $rootPackage->getStabilityFlags())); if ($input->getOption('interactive')) { $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages); diff --git a/src/Composer/Package/Loader/RootPackageLoader.php b/src/Composer/Package/Loader/RootPackageLoader.php index 843a94e69..73c08a41c 100644 --- a/src/Composer/Package/Loader/RootPackageLoader.php +++ b/src/Composer/Package/Loader/RootPackageLoader.php @@ -130,8 +130,8 @@ class RootPackageLoader extends ArrayLoader $links[$link->getTarget()] = $link->getConstraint()->getPrettyString(); } $aliases = $this->extractAliases($links, $aliases); - $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability()); - $references = $this->extractReferences($links, $references); + $stabilityFlags = self::extractStabilityFlags($links, $realPackage->getMinimumStability(), $stabilityFlags); + $references = self::extractReferences($links, $references); if (isset($links[$config['name']])) { throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL . @@ -189,7 +189,10 @@ class RootPackageLoader extends ArrayLoader return $aliases; } - private function extractStabilityFlags(array $requires, array $stabilityFlags, $minimumStability) + /** + * @internal + */ + public static function extractStabilityFlags(array $requires, $minimumStability, array $stabilityFlags) { $stabilities = BasePackage::$stabilities; $minimumStability = $stabilities[$minimumStability]; @@ -242,7 +245,10 @@ class RootPackageLoader extends ArrayLoader return $stabilityFlags; } - private function extractReferences(array $requires, array $references) + /** + * @internal + */ + public static function extractReferences(array $requires, array $references) { foreach ($requires as $reqName => $reqVersion) { $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);