-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Type error results in zero exit code starting with PHP 8.3.0 #53946
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
How did it work before? I believe that before #50420 type error also didn't result in non-zero code. If so then your issue is more like a feature rather than bug. |
These lines are supposed to set it back to 1: symfony/src/Symfony/Component/Console/Application.php Lines 181 to 183 in fd53091
|
New suspect that agrees with @derrabus ' tagging: the error handler component. Here is a reproducer: <?php
use Symfony\Component\ErrorHandler\ErrorHandler;
require_once 'vendor/autoload.php';
ErrorHandler::register();
(function (int $toto): void { echo $toto; })('toto'); |
This problem just caused a lot of confusion for some post deployment commands we have in our K8s cluster. A Adding the following, if others encounter this too, from a slack thread, thanks to @wouterj, will help: // in your bin/console change:
return new Application($kernel);
// to
$app = new Application($kernel);
$app->setCatchErrors(true);
return $app; |
My reproducer above does not seem to always work. I think depending on the php configuration, but I'm really not sure. I discarded the environment because the error handler does not seem to pull much from the env, at least not through |
Ah, this seems to be PHP-8.3-specific 💡 Reported the regression at php/php-src#13446 |
The logic for accessing the exception handler within Before that, fatal errors were handled with the error handler rather than the exception handler. |
Uh oh!
There was an error while loading. Please reload this page.
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
execute
method, it should result in a type error:(function (int $toto): void { echo $toto; })('toto');
echo $?
to get the exit codeYou 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 minorChange this default value and remove the deprecation in the next major version:
symfony/src/Symfony/Component/Console/Application.php
Line 80 in fd53091
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);
.The text was updated successfully, but these errors were encountered: