updated-packages

This commit is contained in:
RafficMohammed
2023-01-08 00:13:22 +05:30
parent 3ff7df7487
commit da241bacb6
12659 changed files with 563377 additions and 510538 deletions

View File

@@ -25,12 +25,12 @@ class JsonFileLoader extends FileLoader
*/
protected function loadResource($resource)
{
$messages = array();
$messages = [];
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)));
throw new InvalidResourceException('Error parsing JSON: '.$this->getJSONErrorMessage($errorCode));
}
}
@@ -39,23 +39,19 @@ class JsonFileLoader extends FileLoader
/**
* Translates JSON_ERROR_* constant into meaningful message.
*
* @param int $errorCode Error code returned by json_last_error() call
*
* @return string Message string
*/
private function getJSONErrorMessage($errorCode)
private function getJSONErrorMessage(int $errorCode): string
{
switch ($errorCode) {
case JSON_ERROR_DEPTH:
case \JSON_ERROR_DEPTH:
return 'Maximum stack depth exceeded';
case JSON_ERROR_STATE_MISMATCH:
case \JSON_ERROR_STATE_MISMATCH:
return 'Underflow or the modes mismatch';
case JSON_ERROR_CTRL_CHAR:
case \JSON_ERROR_CTRL_CHAR:
return 'Unexpected control character found';
case JSON_ERROR_SYNTAX:
case \JSON_ERROR_SYNTAX:
return 'Syntax error, malformed JSON';
case JSON_ERROR_UTF8:
case \JSON_ERROR_UTF8:
return 'Malformed UTF-8 characters, possibly incorrectly encoded';
default:
return 'Unknown error';