Code Inspection: Condition always evaluates to 'true/false'
Reports the conditions that are already covered by earlier conditions and thus have no effect as well as the variables that are always true (or always false) when reached.
In the following example, in case $var
is an instance of the SomeClass
class, then it automatically means that it is not null
. As a result, the subsequent $var === null
condition always resolves to true
and is therefore redundant. After the quick-fix is applied, the redundant condition is removed.
if ($var instanceof SomeClass) {
if ($var === null) {
echo $errorMsg;
}
echo $msg;
}
if ($var instanceof SomeClass) {
echo $msg;
}
Suppress an inspection in the editor
Place 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: 11 February 2024