1.2.1257. Undefined Interfaces¶
Some types or instanceof
that are relying on undefined interfaces or classes: the validation of the type will always fail and return false. Any condition based upon them are dead code.
<?php
class var implements undefinedInterface {
// If undefinedInterface is undefined, this code lints but doesn't run
}
if ($o instanceof undefinedInterface) {
// This is silent dead code
}
function foo(undefinedInterface $a) {
// This is dead code
// it will probably be discovered at execution
}
?>
See also Object interfaces, Type declarations and Instanceof.
1.2.1257.2. Connex PHP features¶
1.2.1257.2.1. Suggestions¶
Implement the missing interfaces
Remove the code governed by the missing interface : the whole method if it is an typehint, the whole if/then if it is a condition.
1.2.1257.2.2. Specs¶
Short name |
Interfaces/UndefinedInterfaces |
Rulesets |
All, Analyze, CE, CI-checks, Changed Behavior, LintButWontExec |
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Major |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Examples |
|
Note |
This issue may lint but will not run |
Available in |