1 | <?php |
||
5 | class Config |
||
6 | { |
||
7 | /** |
||
8 | * |
||
9 | * @var Data |
||
10 | */ |
||
11 | protected static $data; |
||
12 | |||
13 | 5 | public static function init($path) |
|
17 | |||
18 | /** |
||
19 | * |
||
20 | * @return Data |
||
21 | */ |
||
22 | 5 | private static function getData() |
|
29 | |||
30 | 5 | public static function get($key, $default = null) |
|
34 | |||
35 | 1 | public static function set($key, $value) |
|
39 | |||
40 | 1 | public static function setContext($context) |
|
44 | |||
45 | public static function reset() |
||
49 | } |
||
50 |
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: