Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPDoc - Function exits

Is there a way to document that a particular function calls exit()?

The use case is that we have a function that is responsible for handling redirects (checks for already sent headers, set the response code, etc...) and then crucially calls exit(). Unfortunately, PHPStorm has no idea that this particular function terminates execution and thus suggests further warnings as if this function has returned when in practice, it never would.

like image 769
Rob Forrest Avatar asked Sep 27 '22 05:09

Rob Forrest


2 Answers

At the moment it's not possible.

https://youtrack.jetbrains.com/issue/WI-10673 -- watch this ticket (star/vote/comment) to get notified on progress.


ATM I may only suggest placing explicit die() or exit() calls after such function calls.

like image 144
LazyOne Avatar answered Oct 03 '22 02:10

LazyOne


I know it's too old but now you can describe a function or method that calls die() or exit() by using @return never in PHPDoc:

/**
 * @return never
 */
function dead_inside(): void
{
    die();
}
like image 20
Alexey Yashin Avatar answered Oct 03 '22 01:10

Alexey Yashin