Open
Description
Symfony version(s) affected
7.3.0-beta2
Description
As you can see here https://github.com/symfony/symfony/blob/7.3/src/Symfony/Bundle/FrameworkBundle/EventListener/ConsoleProfilerListener.php#L146
// save profiles
foreach ($this->profiles as $r) {
$p = $this->profiles[$r];
$this->profiler->saveProfile($p); // <-- no check here if $p actually exists
// etc...
}
This causes the following exception:
[TypeError]
Symfony\Component\HttpKernel\Profiler\Profiler::saveProfile(): Argument #1 ($profile) must be of type Symfony\Component\HttpKernel\Profiler\Profile, null given, called in /my_project/
vendor/symfony/framework-bundle/EventListener/ConsoleProfilerListener.php on line 147
How to reproduce
This happens to me when calling a specific command with the --profile
argument. I realize this doesn't happen with other commands, but I think anyway the missing check should be added for more consistency
Possible Solution
Replace the code above with the following:
// save profiles
foreach ($this->profiles as $r) {
$p = $this->profiles[$r];
if (null === $p) {
continue;
}
$this->profiler->saveProfile($p);
// etc...
}
Additional Context
No response