Handle better nullable file parameter (#11486)
* Handle better nullable file parameter Closes #11483 * CS fixpull/11497/head
parent
45977c7cb1
commit
8c18de5a41
|
@ -338,12 +338,22 @@ class JsonFile
|
||||||
$result = $parser->lint($json);
|
$result = $parser->lint($json);
|
||||||
if (null === $result) {
|
if (null === $result) {
|
||||||
if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
|
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;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue