Conditions | 3 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | public function __invoke(ContainerInterface $container): ServiceProviderInterface |
||
16 | { |
||
17 | $factories = []; |
||
18 | |||
19 | /** @var array{messenger: array{transports?: array<string, mixed>}} $config */ |
||
20 | $config = $container->has('config') ? $container->get('config') : []; |
||
21 | $transportNames = array_keys($config['messenger']['transports'] ?? []); |
||
22 | |||
23 | foreach ($transportNames as $name) { |
||
24 | $factories[(string) $name] = static function () use ($name, $container): TransportInterface { |
||
25 | /** @var TransportInterface $transport */ |
||
26 | $transport = $container->get((string) $name); |
||
27 | |||
28 | return $transport; |
||
29 | }; |
||
30 | } |
||
31 | |||
32 | return new ServiceProvider(new ServiceManager(['factories' => $factories]), $factories); |
||
33 | } |
||
35 |
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. Please note the @ignore annotation hint above.