Menu

← Back to requireImplements.*

Error Identifier: requireImplements.onEnum

Every error reported by PHPStan has an error identifier. Here’s a list of all error identifiers. In PHPStan Pro you can see the error identifier next to each error and filter errors by their identifiers.

Code example #

<?php declare(strict_types = 1);

interface SomeInterface
{
}

/**
 * @phpstan-require-implements SomeInterface
 */
enum Suit
{
    case Hearts;
    case Diamonds;
}

Why is it reported? #

The @phpstan-require-implements PHPDoc tag is only valid on traits. It is used to declare that any class using the trait must implement a specific interface. Placing it on an enum (or a class) has no effect and is a mistake.

Enums cannot be extended, so the concept of requiring that a using class implements a specific interface does not apply.

How to fix it #

Remove the @phpstan-require-implements tag from the enum. If the enum should implement an interface, declare it directly:

 <?php declare(strict_types = 1);
 
 interface SomeInterface
 {
 }

-/**
- * @phpstan-require-implements SomeInterface
- */
-enum Suit
+enum Suit implements SomeInterface
 {
     case Hearts;
     case Diamonds;
 }

Or move the tag to a trait where it is valid:

 <?php declare(strict_types = 1);
 
 /**
  * @phpstan-require-implements SomeInterface
  */
 trait SomeTrait
 {
 }

How to ignore this error #

You can use the identifier requireImplements.onEnum to ignore this error using a comment:

// @phpstan-ignore requireImplements.onEnum
codeThatProducesTheError();

You can also use only the identifier key to ignore all errors of the same type in your configuration file in the ignoreErrors parameter:

parameters:
	ignoreErrors:
		-
			identifier: requireImplements.onEnum

Rules that report this error #

  • PHPStan\Rules\PhpDoc\RequireImplementsDefinitionClassRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.