diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 1b6f5e7b8..6f1b9ea7c 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -561,10 +561,16 @@ EOT } $lockFile = Factory::getLockFile($this->json->getPath()); if (file_exists($lockFile)) { + $stabilityFlags = RootPackageLoader::extractStabilityFlags($requirements, $composer->getPackage()->getMinimumStability(), []); + $lockMtime = filemtime($lockFile); $lock = new JsonFile($lockFile); $lockData = $lock->read(); $lockData['content-hash'] = Locker::getContentHash($contents); + foreach ($stabilityFlags as $packageName => $flag) { + $lockData['stability-flags'][$packageName] = $flag; + } + ksort($lockData['stability-flags']); $lock->write($lockData); if (is_int($lockMtime)) { @touch($lockFile, $lockMtime); diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 87971cc03..366af3f3f 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -373,6 +373,8 @@ class Locker 'prefer-lowest' => $preferLowest, ]; + ksort($lock['stability-flags']); + $lock['packages'] = $this->lockPackages($packages); if (null !== $devPackages) { $lock['packages-dev'] = $this->lockPackages($devPackages);