[Translation] fixed JSON loader on PHP 7 when file is empty
This commit is contained in:
parent
1e0685711b
commit
af36c341ac
@ -35,10 +35,13 @@ class JsonFileLoader extends ArrayLoader implements LoaderInterface
|
||||
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
|
||||
}
|
||||
|
||||
$messages = json_decode(file_get_contents($resource), true);
|
||||
$messages = array();
|
||||
if ($data = file_get_contents($resource)) {
|
||||
$messages = json_decode($data, true);
|
||||
|
||||
if (0 < $errorCode = json_last_error()) {
|
||||
throw new InvalidResourceException(sprintf('Error parsing JSON - %s', $this->getJSONErrorMessage($errorCode)));
|
||||
if (0 < $errorCode = json_last_error()) {
|
||||
throw new InvalidResourceException(sprintf('Error parsing JSON - %s', $this->getJSONErrorMessage($errorCode)));
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $messages) {
|
||||
|
Reference in New Issue
Block a user