Closed
Description
Symfony version(s) affected
7.0.3
Description
When a type error occurs in a Symfony app that is run with the CLI SAPI, the exit code is zero.
How to reproduce
- paste this in a Symfony command, at the beginning of the
execute
method, it should result in a type error:(function (int $toto): void { echo $toto; })('toto');
- run that command
- run
echo $?
to get the exit code
You should see the type error, and you will also see that it exits with zero, when I would expect it to exit with anything else, just like for exceptions.
Possible Solution
Deprecate not calling setCatchErrors()
in the next minor
Change this default value and remove the deprecation in the next major version:
Additional Context
I cannot reproduce that issue with throw new \Exception
, so maybe it only affects errors.
A workaround is to add $application->setCatchErrors(true);
.