Code Inspection: Result of 'instanceof' is always 'true'
instanceof expressions whose argument is within the hierarchy of the checked variable. Such expressions will always evaluate to
In the following example, the
$this variable is in the context of
ChildClass, which is a direct subclass of
ParentClass. As a result, the
instanceof check always evaluates to
true and the conditional statement becomes redundant. After the quick-fix is applied, the conditional statement is removed.
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.