Code Inspection: Expression is always 'null'
Reports the variables in return
statements that are always null
.
In the following example, the $var
variable returned from within the conditional statement is always null
. After the quick-fix is applied, the variable is replaced with the explicit null
value.
function getValue($var) {
if ($var === null) {
return $var;
}
return $var;
}
function getValue($var) {
if ($var === null) {
return null;
}
return $var;
}
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.
Last modified: 16 May 2022