Conditions | 2 |
Paths | 2 |
Total Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
12 | public function testProvidesAllListeners(): void |
||
13 | { |
||
14 | $event = new Event(); |
||
15 | |||
16 | $provider1 = new class implements ListenerProviderInterface |
||
17 | { |
||
18 | public function getListenersForEvent(object $event): iterable |
||
19 | { |
||
20 | yield function (Event $event) { |
||
21 | $event->register(1); |
||
22 | }; |
||
23 | } |
||
24 | }; |
||
25 | |||
26 | $provider2 = new class implements ListenerProviderInterface |
||
27 | { |
||
28 | public function getListenersForEvent(object $event): iterable |
||
29 | { |
||
30 | yield function (Event $event) { |
||
31 | $event->register(2); |
||
32 | }; |
||
33 | } |
||
34 | }; |
||
35 | |||
36 | $aggregate = new Aggregate(); |
||
37 | |||
38 | $aggregate->attach($provider1); |
||
39 | $aggregate->attach($provider2); |
||
40 | |||
41 | foreach ($aggregate->getListenersForEvent($event) as $listener) { |
||
|
|||
42 | $listener($event); |
||
43 | } |
||
44 | $this->assertEquals([1, 2], $event->registered()); |
||
45 | } |
||
46 | } |
||
47 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: