I try to create a custom command which creates a test user in Symfony 6.0.6 (with PHP 8.1). I tried it with creating a custom command with the following console command:
php bin/console make:command
The command is successfully created under the Command folder, but when I try to run it app:create-user (even without editing the content) I get the following error:
TypeError {#121
#message: "ContainerP1iOqdm\CreateUserCommand_c0d3a03::setName(): Return value must be of type ContainerP1iOqdm\CreateUserCommand_c0d3a03, App\Command\CreateUserCommand returned"
#code: 0
#file: "./var/cache/dev/ContainerP1iOqdm/CreateUserCommand_c0d3a03.php"
#line: 136
trace: {
./var/cache/dev/ContainerP1iOqdm/CreateUserCommand_c0d3a03.php:136 {
ContainerP1iOqdm\CreateUserCommand_c0d3a03->setName(string $name): static^
›
› return $this->valueHolderf0709->setName($name);
› }
}
./vendor/symfony/console/Command/LazyCommand.php:184 { …}
./vendor/symfony/console/Application.php:295 { …}
./vendor/symfony/framework-bundle/Console/Application.php:80 { …}
./vendor/symfony/console/Application.php:171 { …}
./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 { …}
./vendor/autoload_runtime.php:29 { …}
./bin/console:11 { …}
}
}
I already tried to clear the cache, but without success. Even after trying to create a new command I still get the error. I hope someone can help me with.