A function ends the whole program with exit or die

tx0/php:exit-in-functionstrictwarningmaintainability/designdepth fastsmell

What it finds

exit or die inside a function or method ends the whole request from deep inside the code: callers cannot clean up, tests stop, and the response is cut off. Throwing or returning lets the caller decide. Scripts at the top level of a file are left alone.

From the rule's source, exit_in_function.rs.

Example from the rule's tests
<?phpfunction fail($message){    echo $message;    exit(1);tx0 reports: this function ends the whole program} if (!$ok) {    die('stopped');}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/php:exit-in-function" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/php:exit-in-function] reason="..."

tx0 explain tx0/php:exit-in-function shows the same in the terminal. Found a false positive? Report it.