Code Inspection: Inconsistent return points
Configure inspections: Settings | Editor | Inspections
Show intention actions: AltEnter
Reports inconsistencies in function/method exit points.
The following types of inconsistencies are reported:
The function/method contains the
return
statements both with and without arguments.The function/method may return a value or otherwise end its execution without returning anything.
Technically these are not errors, but practically they usually indicate a programming mistake.
In the following example, the inconsistentReturnPoints
function's behavior is inconsistent: it will either return 1
or will not return anything.
function inconsistentReturnPoints() {
if ($a) {
return 1;
} else {
$a = 'Foo';
echo $a;
}
}
Place the caret at the highlighted line and press AltEnter or click
.
Click the arrow next to the inspection you want to suppress and select the necessary suppress action.