| 1 | <?php |
||
| 9 | class DomainMessageListener implements EventListenerInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var MessageEventHandler |
||
| 13 | */ |
||
| 14 | private $handler; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Constructor |
||
| 18 | * |
||
| 19 | * @param MessageEventHandler $handler |
||
| 20 | */ |
||
| 21 | public function __construct(MessageEventHandler $handler) |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Handle an event. |
||
| 28 | * |
||
| 29 | * @param DomainMessage $message |
||
| 30 | * |
||
| 31 | * @return void |
||
| 32 | */ |
||
| 33 | public function handle(DomainMessage $message) |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param DomainMessage $message |
||
| 43 | * |
||
| 44 | * @return mixed |
||
| 45 | */ |
||
| 46 | private static function getContext(DomainMessage $message) |
||
| 53 | } |
||
| 54 |
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: