Conditions | 4 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
42 | 12 | private static function set(array &$array, string $key, $value) |
|
43 | { |
||
44 | 12 | $keys = explode('.', $key); |
|
45 | 12 | while (count($keys) > 1) { |
|
46 | 3 | $key = array_shift($keys); |
|
47 | 3 | if (!isset($array[$key]) || !is_array($array[$key])) { |
|
48 | 3 | $array[$key] = []; |
|
49 | } |
||
50 | 3 | $array =& $array[$key]; |
|
51 | } |
||
52 | 12 | $array[array_shift($keys)] = $value; |
|
53 | } |
||
54 | } |
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: