framework
framework copied to clipboard
[9.x] Allow any Container contract implementation to be used in Seeder
When running PHPStan static analysis on my codebase, I noticed an error Parameter #1 $container of method Illuminate\Database\Seeder::setContainer() expects Illuminate\Container\Container, Illuminate\Contracts\Foundation\Application given.
appearing in a console command I based on the SeedCommand class in this repository.
On further inspection, I noticed this was due to the fact that the getSeeder
method passes $this->laravel
to setContainer
, where $this->laravel
can be any Application
contract implementation, while the $container
property on the Seeder
only explicitly allows the \Illuminate\Container\Container
implementation.
See https://github.com/laravel/framework/blob/8c9ae320512ca7eb784a7e495840d101eb6f92d4/src/Illuminate/Database/Console/Seeds/SeedCommand.php#L109-L111 and https://github.com/laravel/framework/blob/8c9ae320512ca7eb784a7e495840d101eb6f92d4/src/Illuminate/Console/Command.php#L21-L26
As far as I can see, no methods are called that are not part of the contract, however I'm not sure if the more general parameter type might cause problems elsewhere. If so, let me know and I will try to correct for that, or rebase on 10.x
to be more safe.