Skip to content

Type error results in zero exit code starting with PHP 8.3.0 #53946

Closed
@greg0ire

Description

@greg0ire

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:

private bool $catchErrors = false;

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);.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions