From 92105007145688c89420d84ae40c0588edd29dcb Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 2 Oct 2011 20:49:26 +0200 Subject: [PATCH] Handle false and empty decoded json values as valid --- src/Composer/Json/JsonFile.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index 343fbf155..7942d18cd 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -89,8 +89,9 @@ class JsonFile */ public static function parseJson($json) { - $hash = json_decode($json, true); - if (!$hash) { + $data = json_decode($json, true); + + if (false === $data && 'false' !== $json) { switch (json_last_error()) { case JSON_ERROR_NONE: $msg = 'No error has occurred, is your composer.json file empty?'; @@ -114,6 +115,6 @@ class JsonFile throw new \UnexpectedValueException('Incorrect composer.json file: '.$msg); } - return $hash; + return $data; } }