Menu

← Back to interfaceExtends.*

Error Identifier: interfaceExtends.enum

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);

enum Status
{
	case Active;
	case Inactive;
}

interface StatusInterface extends Status // ERROR: Interface StatusInterface extends enum Status.
{
}

Why is it reported? #

An interface cannot extend an enum in PHP. Interfaces can only extend other interfaces. Enums are a distinct type in PHP and cannot be used as a parent type for interfaces. This is a language-level constraint that will cause a fatal error at runtime.

How to fix it #

If the enum implements an interface, extend that interface instead:

 <?php declare(strict_types = 1);
 
+interface HasLabelInterface
+{
+	public function label(): string;
+}
+
 enum Status implements HasLabelInterface
 {
 	case Active;
 	case Inactive;

 	public function label(): string
 	{
 		return $this->name;
 	}
 }

-interface StatusInterface extends Status
+interface StatusInterface extends HasLabelInterface
 {
 }

If the intent is to type-hint against the enum, use the enum name directly as a type:

<?php declare(strict_types = 1);

function processStatus(Status $status): void
{
	// ...
}

Non-ignorable error #

This error cannot be ignored using @phpstan-ignore or the ignoreErrors configuration. Non-ignorable errors indicate code that would cause a crash or a fatal error at runtime, or a fundamental problem in the analysed code that must be addressed.

Rules that report this error #

  • PHPStan\Rules\Classes\ExistingClassesInInterfaceExtendsRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.