| 1 | <?php |
||
| 7 | abstract class Token |
||
| 8 | { |
||
| 9 | public $type; |
||
| 10 | public $value; |
||
| 11 | public $location; |
||
| 12 | |||
| 13 | 81 | final public function __construct($type, $value, Location $location) |
|
| 19 | |||
| 20 | 15 | final private static function getNames() |
|
| 35 | |||
| 36 | 15 | final public static function getNameFor($type) |
|
| 42 | |||
| 43 | 15 | final public function getName() |
|
| 47 | } |
||
| 48 |
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: