thomasvargiu /
laminas-messenger
| 1 | <?php |
||||
| 2 | |||||
| 3 | declare(strict_types=1); |
||||
| 4 | |||||
| 5 | namespace TMV\Laminas\Messenger\Factory\Transport; |
||||
| 6 | |||||
| 7 | use Laminas\ServiceManager\ServiceManager; |
||||
| 8 | use Psr\Container\ContainerInterface; |
||||
| 9 | use Symfony\Component\Messenger\Transport\TransportInterface; |
||||
| 10 | use Symfony\Contracts\Service\ServiceProviderInterface; |
||||
| 11 | use TMV\Laminas\Messenger\ServiceProvider; |
||||
| 12 | |||||
| 13 | class TransportProviderFactory |
||||
| 14 | { |
||||
| 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); |
||||
|
0 ignored issues
–
show
new Laminas\ServiceManag...tories' => $factories)) of type Laminas\ServiceManager\ServiceManager is incompatible with the type array expected by parameter $factories of TMV\Laminas\Messenger\Se...Provider::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 33 | } |
||||
| 34 | } |
||||
| 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.