| 1 | <?php |
||
| 10 | class ChannelServiceProvider extends ServiceProvider |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Register the service provider. |
||
| 14 | * |
||
| 15 | * @return void |
||
| 16 | */ |
||
| 17 | public function register(): void |
||
| 18 | { |
||
| 19 | 83 | $this->app->singleton(ChannelManager::class, function () { |
|
| 20 | /** @var array $channels */ |
||
| 21 | $channels = collect($this->config()) |
||
| 22 | ->mapWithKeys(function (array $parameters, string $name) { |
||
| 23 | return [$name => $parameters]; |
||
| 24 | }) |
||
| 25 | ->toArray(); |
||
| 26 | |||
| 27 | $manager = new ChannelManager($this->app); |
||
|
|
|||
| 28 | $manager->register($channels); |
||
| 29 | |||
| 30 | return $manager; |
||
| 31 | 83 | }); |
|
| 32 | 83 | } |
|
| 33 | |||
| 34 | private function config(): array |
||
| 41 | } |
||
| 42 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.