1 | <?php |
||
11 | trait EventsEmitter |
||
12 | { |
||
13 | /** |
||
14 | * @var Emitter |
||
15 | */ |
||
16 | public static $events; |
||
17 | |||
18 | /** |
||
19 | * Boot events emitter. |
||
20 | */ |
||
21 | 9 | public function bootEvents() |
|
27 | |||
28 | /** |
||
29 | * Boot event listeners. |
||
30 | */ |
||
31 | 9 | protected function bootListeners() |
|
39 | |||
40 | /** |
||
41 | * Emit event. |
||
42 | * |
||
43 | * @return \League\Event\EventInterface|string |
||
44 | */ |
||
45 | 4 | public static function emit() |
|
49 | |||
50 | /** |
||
51 | * Emit event. |
||
52 | * |
||
53 | * @param string $event |
||
54 | * @param ListenerInterface|callable $listener |
||
55 | * @return EventInterface|string |
||
56 | */ |
||
57 | 1 | public static function on($event, $listener) |
|
61 | |||
62 | /** |
||
63 | * Remove listeners. |
||
64 | * |
||
65 | * @param $event |
||
66 | */ |
||
67 | 1 | public static function off($event) |
|
71 | |||
72 | /** |
||
73 | * Make statistics storage. |
||
74 | * |
||
75 | * @return AbstractStorage|null |
||
76 | */ |
||
77 | 9 | protected function makeStatisticsStorage() |
|
88 | } |
||
89 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: