Code Inspection: 'never'-typed function returns a value
Reports the functions with the never
return type hint that may return some value. Functions with such a return type are not expected to return any value and must prevent the rest of the script execution by either calling die()
, exit()
, and so on, or throwing an exception.
See noreturn type (php.net) for details.
In the following example, the function exampleFunction
does not terminate the script execution in any way, which will result in a PHP TypeError
:
In the following example, the function exampleFunction
explicitly returns a value, which will result in a PHP Fatal error
:
Suppress an inspection in the editor
Position the caret at the highlighted line and press Alt+Enter or click .
Click the arrow next to the inspection you want to suppress and select the necessary suppress action.