diff --git a/src/Illuminate/Http/JsonResponse.php b/src/Illuminate/Http/JsonResponse.php index 7bf257b93b37..9baf417b01b6 100755 --- a/src/Illuminate/Http/JsonResponse.php +++ b/src/Illuminate/Http/JsonResponse.php @@ -86,24 +86,16 @@ public function setData($data = []) */ protected function hasValidJson($jsonError) { - // No error is obviously fine if ($jsonError === JSON_ERROR_NONE) { return true; } - // If the JSON_PARTIAL_OUTPUT_ON_ERROR option is set, some additional errors are fine - // (see https://secure.php.net/manual/en/json.constants.php) - if ($this->hasEncodingOption(JSON_PARTIAL_OUTPUT_ON_ERROR)) { - $acceptableErrors = [ - JSON_ERROR_RECURSION, - JSON_ERROR_INF_OR_NAN, - JSON_ERROR_UNSUPPORTED_TYPE, - ]; - - return \in_array($jsonError, $acceptableErrors); - } - - return false; + return $this->hasEncodingOption(JSON_PARTIAL_OUTPUT_ON_ERROR) && + in_array($jsonError, [ + JSON_ERROR_RECURSION, + JSON_ERROR_INF_OR_NAN, + JSON_ERROR_UNSUPPORTED_TYPE, + ]); } /**