1.2.476. Forgotten Interface

The following classes have been found implementing an interface’s methods, though it doesn’t explicitly implements this interface. This may have been forgotten.

<?php

interface i {
    function i();
}

// i is not implemented and declared
class foo {
    function i() {}
    function j() {}
}

// i is implemented and declared
class foo implements i {
    function i() {}
    function j() {}
}

?>

See also Could Use Trait.

1.2.476.1. Suggestions

  • Mention interfaces explicitly whenever possible

1.2.476.2. Specs

Short name

Interfaces/CouldUseInterface

Rulesets

All, Analyze, Changed Behavior

Exakat since

0.11.7

PHP Version

All

Severity

Minor

Time To Fix

Quick (30 mins)

Precision

High

Features

interface, ducktyping

Available in

Entreprise Edition, Exakat Cloud