1 | <?php |
||
32 | return new class($dispatcher) implements EventDispatcherInterface { |
||
33 | /** |
||
34 | * @var EventDispatcherInterface |
||
35 | */ |
||
36 | private $dispatcher; |
||
37 | |||
38 | /** |
||
39 | * @param EventDispatcherInterface $dispatcher |
||
40 | */ |
||
41 | 43 | public function __construct(EventDispatcherInterface $dispatcher) |
|
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | 24 | public function dispatch($eventName/*, object $event = null*/) |
|
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | 5 | public function addListener($eventName, $listener, $priority = 0) |
|
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | public function addSubscriber(EventSubscriberInterface $subscriber) |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public function removeListener($eventName, $listener) |
||
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | public function removeSubscriber(EventSubscriberInterface $subscriber) |
||
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | public function getListeners($eventName = null): array |
||
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | public function getListenerPriority($eventName, $listener): ?int |
||
107 | |||
108 | /** |
||
109 | * {@inheritdoc} |
||
110 | */ |
||
111 | public function hasListeners($eventName = null): bool |
||
115 | |||
116 | /** |
||
117 | * Proxies all method calls to the original event dispatcher. |
||
118 | */ |
||
119 | public function __call($method, $arguments) |
||
123 | }; |
||
124 | } |
||
126 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.