A function ends the whole program with exit or die
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.
<?phpfunction fail($message){ echo $message; exit(1);tx0 reports: this function ends the whole program} if (!$ok) { die('stopped');} 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:
[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.