Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Non-enum class %s cannot implement interface %s

Description

UnitEnum is an PHP native and reserved interface. It is only used with enumerations. It is also handled by PHP itself, which adds it to enumerations: there is no need to add it explictly. This applies to BackedEnum and UnitEnum, as of PHP 8.4.

Example

<?php

    class X implements YnitEnum {}

?>

Literal Examples

  • Non-enum class x cannot implement interface UnitEnum
  • Non-enum class x cannot implement interface BackEnum

Alternatives

  • Turn the class into an enumeration.
  • Remove the UnitEnum implementation.