From e1a3df3dbfe16ae928ec78318b71941ff9f319cf Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Mon, 25 Aug 2014 21:52:36 +0200 Subject: [PATCH] Fixed the registration of commands with invalid JSON file When the JSON file in the current folder is invalid, the registration of custom commands should be ignored rather than breaking the usage of Composer entirely. Closes #3165 --- src/Composer/Console/Application.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php index 4e2fa14b2..524b01df3 100644 --- a/src/Composer/Console/Application.php +++ b/src/Composer/Console/Application.php @@ -113,8 +113,7 @@ class Application extends BaseApplication // add non-standard scripts as own commands $file = Factory::getComposerFile(); - $json = new JsonFile($file); - if ($json->exists() && is_readable($file) && ($composer = $json->read())) { + if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) { if (isset($composer['scripts']) && is_array($composer['scripts'])) { foreach ($composer['scripts'] as $script => $dummy) { if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {