Skip to content

Parameter #1 $callback of function set_error_handler #4416

@proton-ab

Description

@proton-ab

Bug report

In the snippets below, I use set_error_handler to selectively override handler for E_ERROR | E_PARSE and call die() inside. PHPStan believes that void is not a valid return typo for set_error_handler, however this is very much valid usage pattern because the execution flow ends with a call to die() and as such, the return value of the error handler function is of no concerns.

Code snippet that reproduces the problem

https://phpstan.org/r/28a69dd0-5f1a-483d-8d8d-1feb90796a61
https://phpstan.org/r/b1ad83dc-8740-464a-83c6-c9efec042e14

Expected output

PHPStan understands that the execution flow ends due to die().
Do note that equivalent snippet with set_exception_handler is properly handled: https://phpstan.org/r/3c621be7-b31c-4cd7-8926-b9affa50c4e4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions