1 | <?php |
||
17 | class Json implements ParserInterface |
||
18 | { |
||
19 | /** |
||
20 | * {@inheritDoc} |
||
21 | * Parses an JSON file as an array |
||
22 | * |
||
23 | * @throws ParseException If there is an error parsing the JSON file |
||
24 | */ |
||
25 | 6 | public function parseFile($filename) |
|
30 | |||
31 | /** |
||
32 | * {@inheritDoc} |
||
33 | * Parses an JSON string as an array |
||
34 | * |
||
35 | * @throws ParseException If there is an error parsing the JSON string |
||
36 | */ |
||
37 | 3 | public function parseString($config) |
|
42 | |||
43 | /** |
||
44 | * Completes parsing of JSON data |
||
45 | * |
||
46 | * @param array $data |
||
47 | * @param strring $filename |
||
48 | * |
||
49 | * @throws ParseException If there is an error parsing the JSON data |
||
50 | */ |
||
51 | 6 | protected function parse($data = null, $filename = null) |
|
52 | { |
||
53 | 6 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
54 | 3 | $error_message = 'Syntax error'; |
|
55 | 3 | if (function_exists('json_last_error_msg')) { |
|
56 | 3 | $error_message = json_last_error_msg(); |
|
57 | } |
||
58 | |||
59 | $error = [ |
||
60 | 3 | 'message' => $error_message, |
|
61 | 3 | 'type' => json_last_error(), |
|
62 | 3 | 'file' => $filename, |
|
63 | ]; |
||
64 | 3 | throw new ParseException($error); |
|
65 | } |
||
66 | |||
67 | 3 | return $data; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * {@inheritDoc} |
||
72 | */ |
||
73 | 3 | public static function getSupportedExtensions() |
|
77 | } |
||
78 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: