1.2.1034. 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.1034.1. Suggestions

  • Remove the interface usage at the lowest class or interface

1.2.1034.2. Specs

Short name

Interfaces/RepeatedInterface

Rulesets

All, Analyze, Changed Behavior, LintButWontExec

Exakat since

1.4.9

PHP Version

All

Severity

Minor

Time To Fix

Instant (5 mins)

Precision

High

Features

interface

Note

This issue may lint but will not run

Available in

Entreprise Edition, Exakat Cloud