1.2.1397. Useless Interfaces¶
The interfaces below are defined and are implemented by some classes.
However, they are never used to enforce an object’s class in the code, using instanceof
or in a type.
As they are currently used, those interfaces may be removed without change in behavior.
Interfaces should be used in type or with the instanceof
operator.
<?php
// only defined interface but never enforced
interface i {};
class c implements i {}
?>
1.2.1397.1. Connex PHP features¶
1.2.1397.1.1. Suggestions¶
Use the interface with instanceof, or a type
Drop the interface altogether : both definition and implements keyword
1.2.1397.1.2. Specs¶
Short name |
Interfaces/UselessInterfaces |
Rulesets |
|
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
ClearPHP |
|
Examples |
|
Available in |