diff --git a/src/Composer/Json/JsonFile.php b/src/Composer/Json/JsonFile.php index d4f851f8a..3ad34a619 100644 --- a/src/Composer/Json/JsonFile.php +++ b/src/Composer/Json/JsonFile.php @@ -338,12 +338,22 @@ class JsonFile $result = $parser->lint($json); if (null === $result) { if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) { - throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON'); + if ($file === null) { + throw new \UnexpectedValueException('The input is not UTF-8, could not parse as JSON'); + } else { + throw new \UnexpectedValueException('"' . $file . '" is not UTF-8, could not parse as JSON'); + } } return true; } - throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails()); + if ($file === null) { + throw new ParsingException('The input does not contain valid JSON' . "\n" . $result->getMessage(), + $result->getDetails()); + } else { + throw new ParsingException('"' . $file . '" does not contain valid JSON' . "\n" . $result->getMessage(), + $result->getDetails()); + } } }