Menu

← Back to enum.*

Error Identifier: enum.missingCase

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: string
{
	case Active = 'active';
	case Inactive;
}

Why is it reported? #

In a backed enum, every case must have a value. When an enum declares a scalar backing type (such as string or int), each case is required to provide an explicit value of that type. Unlike pure enums where cases have no values, backed enums require a value assignment for every case.

How to fix it #

Add a value to the case that is missing one:

 enum Status: string
 {
 	case Active = 'active';
-	case Inactive;
+	case Inactive = 'inactive';
 }

Alternatively, if the enum should not be backed, remove the scalar type:

-enum Status: string
+enum Status
 {
-	case Active = 'active';
-	case Inactive;
+	case Active;
+	case Inactive;
 }

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\EnumSanityRule [1]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.