%s %s must implement interface %s as part of either %s or %s

Description

It is not possible to implement directly the mentionned interface. That interface is actually implemented by a selection of PHP native classes: these classes may be extended, and, as such, the children classes also implements the initial interface.

This error message is applicable to a few PHP native interfaces, such as Throwable (via Error and Exception) and Traversable (via Iterator and IteratorAggregate).

Example

<?php

enum E implements Traversable {}

class X implements Throwable {}

?>

Literal Examples

  • Enum Foo must implement interface Traversable as part of either Iterator or IteratorAggregate

  • Class X cannot implement interface Throwable, extend Exception or Error instead

Solutions

  • Extends one of the classes mentionned in the error message.

  • Remove the implementats and its interface.

In previous PHP versions, this error message used to be Class %s must implement interface %s as part of either %s or %s.