diff --git a/build/kint.phar b/build/kint.phar index f2d8265cb..e407ade62 100644 Binary files a/build/kint.phar and b/build/kint.phar differ diff --git a/src/Utils.php b/src/Utils.php index 5143731c7..aa62bf623 100644 --- a/src/Utils.php +++ b/src/Utils.php @@ -109,6 +109,10 @@ public static function composerGetExtras($key = 'kint') if (\file_exists($installed) && \is_readable($installed)) { $packages = \json_decode(\file_get_contents($installed), true); + if (!\is_array($packages)) { + continue; + } + foreach ($packages as $package) { if (isset($package['extra'][$key]) && \is_array($package['extra'][$key])) { $extras = \array_replace($extras, $package['extra'][$key]); diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php index f5c1ba883..274856368 100644 --- a/tests/UtilsTest.php +++ b/tests/UtilsTest.php @@ -259,6 +259,9 @@ public function testComposerGetExtras() ])); $this->assertSame(['more' => 'test', 'data', 'test' => 'ing'], Utils::composerGetExtras('kint')); + + \file_put_contents($this->composer_test_dir.'/composer/installed.json', 'malformed JSON.'); + $this->assertSame([], Utils::composerGetExtras('kint')); } public function traceProvider()