1 | <?php |
||
13 | final class ProjectEnabledDispatcher implements EventDispatcher |
||
14 | { |
||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | private $listeners = []; |
||
19 | |||
20 | /** |
||
21 | * @param string $eventName |
||
22 | * @param array $arguments |
||
23 | * @param bool $runProjectionsOnly |
||
24 | */ |
||
25 | 24 | public function dispatch($eventName, array $arguments, $runProjectionsOnly = false) |
|
36 | |||
37 | /** |
||
38 | * @param string $eventName |
||
39 | * @param callable $callable |
||
40 | * @param int $priority |
||
41 | */ |
||
42 | 24 | public function addListener($eventName, callable $callable, $priority = 0) |
|
49 | |||
50 | |||
51 | /** |
||
52 | * @param Subscriber $subscriber |
||
53 | * @return void |
||
54 | */ |
||
55 | 6 | public function addSubscriber(Subscriber $subscriber) |
|
69 | |||
70 | /** |
||
71 | * @param $runProjectionsOnly |
||
72 | * @param $listener |
||
73 | * @return bool |
||
74 | */ |
||
75 | 21 | protected function listenerCanRun($runProjectionsOnly, $listener) |
|
79 | |||
80 | /** |
||
81 | * @param $eventName |
||
82 | * @return array |
||
83 | */ |
||
84 | 21 | protected function getListenersInOrder($eventName) |
|
95 | |||
96 | /** |
||
97 | * Sorts the internal list of listeners for the given event by priority. |
||
98 | * |
||
99 | * @param string $eventName The name of the event. |
||
100 | */ |
||
101 | 21 | private function sortListeners($eventName) |
|
108 | } |
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: