| 1 | <?php |
||
| 10 | class Util |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @return float |
||
| 14 | */ |
||
| 15 | public static function random() |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param $id |
||
| 22 | * @return float |
||
| 23 | */ |
||
| 24 | public static function randomById($id) |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param array $array |
||
| 31 | * @param string $key |
||
| 32 | * @param null|mixed $default |
||
| 33 | * @return null|mixed |
||
| 34 | */ |
||
| 35 | public static function arrayGet(array $array, $key, $default = null) |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param string $hex |
||
| 42 | * @return float |
||
| 43 | */ |
||
| 44 | private static function mapHex($hex) |
||
| 56 | } |
||
| 57 |
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
SomeClassto useselfinstead: