| 1 | <?php |
||
| 9 | abstract class Enum |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var |
||
| 13 | */ |
||
| 14 | protected $enumValue; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var array |
||
| 18 | */ |
||
| 19 | protected static $cache = array(); |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Enum constructor. |
||
| 23 | * @param $enumValue |
||
| 24 | */ |
||
| 25 | public function __construct($enumValue) |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param $enumValue |
||
| 38 | * @return bool |
||
| 39 | */ |
||
| 40 | private static function isPartFromTheClass($enumValue) |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @return void |
||
| 48 | * @throws \ReflectionException |
||
| 49 | */ |
||
| 50 | private static function setCacheArray() |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | public function __toString() |
||
| 64 | } |
||
| 65 |
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: