From 850bfcddfa946984e083b9111664d502304654ce Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 14 Feb 2020 09:33:53 +0100 Subject: [PATCH] Fix json manipulation fallback handling of empty objects, fixes #8600 --- src/Composer/Config/JsonConfigSource.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Composer/Config/JsonConfigSource.php b/src/Composer/Config/JsonConfigSource.php index 15d40d200..f455845a4 100644 --- a/src/Composer/Config/JsonConfigSource.php +++ b/src/Composer/Config/JsonConfigSource.php @@ -246,6 +246,12 @@ class JsonConfigSource implements ConfigSourceInterface $config = $this->file->read(); $this->arrayUnshiftRef($args, $config); call_user_func_array($fallback, $args); + // avoid ending up with arrays for keys that should be objects + foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev') as $linkType) { + if (isset($config[$linkType]) && $config[$linkType] === array()) { + $config[$linkType] = new \stdClass; + } + } $this->file->write($config); }