1 | <?php |
||
17 | class Ini implements ParserInterface |
||
18 | { |
||
19 | /** |
||
20 | * {@inheritDoc} |
||
21 | * Parses an INI file as an array |
||
22 | * |
||
23 | * @throws ParseException If there is an error parsing the INI file |
||
24 | */ |
||
25 | 9 | public function parseFile($filename) |
|
30 | |||
31 | /** |
||
32 | * {@inheritDoc} |
||
33 | * Parses an INI string as an array |
||
34 | * |
||
35 | * @throws ParseException If there is an error parsing the INI string |
||
36 | */ |
||
37 | 9 | public function parseString($config) |
|
42 | |||
43 | /** |
||
44 | * Completes parsing of INI data |
||
45 | * |
||
46 | * @param array $data |
||
47 | * @param strring $filename |
||
48 | * |
||
49 | * @throws ParseException If there is an error parsing the INI data |
||
50 | */ |
||
51 | 12 | protected function parse($data = null, $filename = null) |
|
52 | { |
||
53 | 12 | if (!$data) { |
|
54 | 6 | $error = error_get_last(); |
|
55 | |||
56 | // Parse functions may return NULL but set no error if the string contains no parsable data |
||
57 | 6 | if (!is_array($error)) { |
|
58 | 3 | $error["message"] = "No parsable content in data."; |
|
59 | } |
||
60 | |||
61 | 6 | $error["file"] = $filename; |
|
62 | |||
63 | // if string contains no parsable data, no error is set, resulting in any previous error |
||
64 | // persisting in error_get_last(). in php 7 this can be addressed with error_clear_last() |
||
65 | 6 | if (function_exists("error_clear_last")) { |
|
66 | 6 | error_clear_last(); |
|
67 | } |
||
68 | |||
69 | 6 | throw new ParseException($error); |
|
70 | } |
||
71 | |||
72 | 6 | return $this->expandDottedKey($data); |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * Expand array with dotted keys to multidimensional array |
||
77 | * |
||
78 | * @param array $data |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | 3 | protected function expandDottedKey($data) |
|
83 | { |
||
84 | 3 | foreach ($data as $key => $value) { |
|
85 | 3 | if (($found = strpos($key, '.')) !== false) { |
|
86 | 3 | $newKey = substr($key, 0, $found); |
|
87 | 3 | $remainder = substr($key, $found + 1); |
|
88 | |||
89 | 3 | $expandedValue = $this->expandDottedKey([$remainder => $value]); |
|
90 | 3 | if (isset($data[$newKey])) { |
|
91 | 3 | $data[$newKey] = array_merge_recursive($data[$newKey], $expandedValue); |
|
92 | } else { |
||
93 | 3 | $data[$newKey] = $expandedValue; |
|
94 | } |
||
95 | 3 | unset($data[$key]); |
|
96 | } |
||
97 | } |
||
98 | 3 | return $data; |
|
99 | } |
||
100 | |||
101 | /** |
||
102 | * {@inheritDoc} |
||
103 | */ |
||
104 | 3 | public static function getSupportedExtensions() |
|
108 | } |
||
109 |
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: