Class %s cannot implement previously implemented interface %s

Description

It is not allowed to use several times the same interface in a implements clause, for classes, or extends for interfaces.

The message is a bit confusing, since the interface is not already implemented, but rather, used in the implements clause. In fact, PHP checks first the list of names of the clause, then it checks the signatures of the methods.

This error message is dependent on the use expresion, and also the calls to class_alias().

Example

<?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 {}

?>

Literal Examples

  • Class foo cannot implement previously implemented interface i

Solutions

  • Remove the duplicate interface name.