diff --git a/composer.lock b/composer.lock index 8ed996808..55d1cf38e 100644 --- a/composer.lock +++ b/composer.lock @@ -2381,13 +2381,13 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { "php": "^7.2.5 || ^8.0" }, - "platform-dev": [], + "platform-dev": {}, "platform-overrides": { "php": "7.2.5" }, diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 366af3f3f..dc33a1123 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -368,20 +368,22 @@ class Locker 'packages-dev' => null, 'aliases' => $aliases, 'minimum-stability' => $minimumStability, - 'stability-flags' => $stabilityFlags, + 'stability-flags' => \count($stabilityFlags) > 0 ? $stabilityFlags : new \stdClass, 'prefer-stable' => $preferStable, 'prefer-lowest' => $preferLowest, ]; - ksort($lock['stability-flags']); + if (is_array($lock['stability-flags'])) { + ksort($lock['stability-flags']); + } $lock['packages'] = $this->lockPackages($packages); if (null !== $devPackages) { $lock['packages-dev'] = $this->lockPackages($devPackages); } - $lock['platform'] = $platformReqs; - $lock['platform-dev'] = $platformDevReqs; + $lock['platform'] = \count($platformReqs) > 0 ? $platformReqs : new \stdClass; + $lock['platform-dev'] = \count($platformDevReqs) > 0 ? $platformDevReqs : new \stdClass; if (\count($platformOverrides) > 0) { $lock['platform-overrides'] = $platformOverrides; }