1.2.1042. Repeated Interface¶
A class should implements only once an interface. An interface can only extends once another interface. In both cases, parent classes or interfaces must be checked.
PHP accepts multiple times the same interface in the implements
clause. In fact, it doesn’t do anything beyond the first implement.
This code may compile, but won’t execute.
<?php
use i as j;
interface i {}
// Multiple ways to reference an interface
class foo implements i, \i, j {}
// This applies to interfaces too
interface bar extends i, \i, j {}
?>
See also Object Interfaces and The Basics.
1.2.1042.2. Connex PHP features¶
1.2.1042.2.1. Suggestions¶
Remove the interface usage at the lowest class or interface
1.2.1042.2.2. Specs¶
Short name |
Interfaces/RepeatedInterface |
Rulesets |
|
Exakat since |
1.4.9 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Instant (5 mins) |
Precision |
High |
Note |
This issue may lint but will not run |
Available in |