| 1 | <?php |
||
| 13 | class ContextStack |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var array |
||
| 17 | */ |
||
| 18 | private static $queueHandler; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Statically create an instance of this class. |
||
| 22 | * |
||
| 23 | * @param TaskQueue |
||
| 24 | */ |
||
| 25 | public static function create() |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Store a value into task queueing stack. |
||
| 36 | * |
||
| 37 | * @param \Closure|array $handler |
||
| 38 | * @param mixed $value |
||
| 39 | */ |
||
| 40 | public function store($handler, $value = []) |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Get task queue handler. |
||
| 55 | * |
||
| 56 | * @return TaskQueue |
||
| 57 | */ |
||
| 58 | public static function getQueueHandler() |
||
| 62 | } |
||
| 63 |
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: