-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Description
Symfony version(s) affected
7.4
Description
Using the --profile option to debug a console command causes a TypeError to be thrown by the TraceableCommand class on line 172.
TypeError {#253
#message: "ReflectionFunction::__construct(): Argument #1 ($function) must be of type Closure|string, App\Command\HelloWorldCommand given"
#code: 0
#file: "./vendor/symfony/console/Command/TraceableCommand.php"
#line: 172
trace: {
./vendor/symfony/console/Command/TraceableCommand.php:172 { …}
./vendor/symfony/console/Command/TraceableCommand.php:71 { …}
./vendor/symfony/framework-bundle/Console/Application.php:115 { …}
./vendor/symfony/console/Application.php:356 { …}
./vendor/symfony/framework-bundle/Console/Application.php:77 { …}
./vendor/symfony/console/Application.php:195 { …}
./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:49 { …}
./vendor/autoload_runtime.php:32 { …}
./bin/console:15 {
›
› require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
›
arguments: {
"/path/to/symfony/app/console-test/vendor/autoload_runtime.php"
}
}
}
}
How to reproduce
- Create a brand new Symfony 7.4 application with the command:
symfony new --webapp --version="7.4.x" console-test - Create a file in
src/Command/namedHelloWorldCommand.phpwith the following contents:
<?php
namespace App\Command;
use Symfony\Component\Console\Attribute\Argument;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Style\SymfonyStyle;
#[AsCommand(name: 'app:hello:world')]
final readonly class HelloWorldCommand
{
public function __invoke(SymfonyStyle $io, #[Argument] string $name): int
{
$io->title('Hello World');
$io->writeln(sprintf('Hello, %s!', $name));
return Command::SUCCESS;
}
}- Attempt to run the command with the
--profileoption to see the error above:php bin/console app:hello:world Vic --profile
Notes
- Running the command without the
--profileoption works as expected. - Doesn't matter if the development web server is running or not.
- Doesn't matter where the
--profileoption is located in the command line. Bothphp bin/console --profile app:hello:world Vicandphp bin/console app:hello:world --profile Vicfail.
Possible Solution
No response
Additional Context
Was this possibly broken by #61134 and #61138? I thought I messed up the migration from 7.3.7 to 7.4.0, but getting the same error with a brand new stock install of 7.4.0 confirmed it's not my actual codebase.
santysisi