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 explictely. 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

Solutions

  • Turn the class into an enumeration.

  • Remove the UnitEnum implementation.