You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because of \Illuminate\Console\Command::call() method docblock, it must accept any kinds of Symfony Command instances. But it does not and raise an error.
Inside a 10.x Laravel project, create a "demo" command like this:
<?phpnamespaceApp\Console\Commands;
useIlluminate\Console\Command;
useIlluminate\Foundation\Console\ViewClearCommand;
class DemoCommand extends Command
{
protected$signature = 'demo';
protected$description = 'This is "demo" command description';
publicfunctionhandle()
{
$this->call('view:clear'); // It works properly.$this->call(ViewClearCommand::class); // It works properly.$this->call(
$this->laravel->make(ViewClearCommand::class) // It does not work and raise an error.
);
}
}
Open the termial, go to the project directory and run "php artisan demo".
INFO Compiled views cleared successfully.
INFO Compiled views cleared successfully.
TypeError
class_exists(): Argument #1 ($class) must be of type string, Illuminate\Foundation\Console\ViewClearCommand given
at vendor\laravel\framework\src\Illuminate\Console\Command.php:245
241▕ * @return \Symfony\Component\Console\Command\Command
242▕ */
243▕ protected functionresolveCommand($command)
244▕ {
➜ 245▕ if (! class_exists($command)) {
246▕ return$this->getApplication()->find($command);
247▕ }
248▕
249▕ $command = $this->laravel->make($command);
1 vendor\laravel\framework\src\Illuminate\Console\Command.php:245
2 vendor\laravel\framework\src\Illuminate\Console\Concerns\CallsCommands.php:67
Illuminate\Console\Command::resolveCommand(Object(Illuminate\Foundation\Console\ViewClearCommand))
When we pass a Command instance through call method, it continues passing through resolveCommand method. There, class_exists requires a string as the first parameter and an error is raised here.
We should either update call method to accept string only or update checks inside resolveCommand.
The text was updated successfully, but these errors were encountered:
Laravel Version
10.x
PHP Version
8.3
Database Driver & Version
No response
Description
Because of \Illuminate\Console\Command::call() method docblock, it must accept any kinds of Symfony Command instances. But it does not and raise an error.
Steps To Reproduce
When we pass a Command instance through
call
method, it continues passing throughresolveCommand
method. There,class_exists
requires a string as the first parameter and an error is raised here.We should either update
call
method to accept string only or update checks insideresolveCommand
.The text was updated successfully, but these errors were encountered: