%s %s cannot implement previously implemented interface %s

Description

This error reports that an interface has already been implemented by a parent, and, as such, should not be implemented again.

For enumerations, it applies to BackEnum and UnitEnum, as enumerations don’t have parents.

For interfaces and classes, it applies to repetitions of interfaces in the implements list.

It doesn’t apply to duplicate implements between a parent and a child class or interface.

It doesn’t apply to trait, that have no relationship with interfaces.

Example

<?php

enum X implements UnitEnum {}

interface J extends I, I {}

class X implements I {}

// This is OK
// It is also duplicate and useless, but valid.
class Y extends X implements I {}

?>

Literal Examples

  • Enum x cannot implement previously implemented interface UnitEnum

Solutions

  • Remove duplicate interfaces from the implements keyword on classes.

  • Remove duplicate interfaces from the extends keyword on interfaces.

  • Remove BackEnum and UnitEnum from the implements keyword on an enumeration.