1.2.590. Interfaces Is Not Implemented¶
Classes that implements interfaces, must implements each of the interface’s methods. Otherwise, the class shall be marked as abstract
.
This problem tends to occur in code that splits interfaces and classes by file. This means that PHP’s linting will skip the definitions and not find the problem. At execution time, the definitions will be checked, and a Fatal error will occur.
This situation usually detects code that was forgotten during a refactorisation of the interface or the class and its siblings.
<?php
class x implements i {
// This method implements the foo method from the i interface
function foo() {}
// The method bar is missing, yet is requested by interface i
function foo() {}
}
interface i {
function foo();
function bar();
}
?>
See also Interfaces.
1.2.590.2. Connex PHP features¶
1.2.590.2.1. Suggestions¶
Implements all the methods from the interfaces
Remove the class
Make the class abstract
Make the missing methods abstract
1.2.590.2.2. Specs¶
Short name |
Interfaces/IsNotImplemented |
Rulesets |
All, Analyze, CE, CI-checks, Changed Behavior, Class Review, LintButWontExec |
Exakat since |
1.9.5 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
High |
Note |
This issue may lint but will not run |
Available in |