Menu

Error Identifier: return.internalEnum

← Back to return.*

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

namespace Vendor {
	/** @internal */
	enum InternalStatus {
		case Active;
	}
}

namespace App {
	function getStatus(): \Vendor\InternalStatus {
		return \Vendor\InternalStatus::Active;
	}
}

Why is it reported? #

The native return type declaration of a function or method references an enum that is marked as @internal. Internal enums are not part of the public API of the package that defines them. Exposing an internal enum in a return type creates a dependency on an implementation detail that may change or be removed without notice.

How to fix it #

Replace the internal enum with a public enum or interface from the package in the return type:

 namespace App {
-	function getStatus(): \Vendor\InternalStatus {
-		return \Vendor\InternalStatus::Active;
+	function getStatus(): \Vendor\PublicStatus {
+		// ...
 	}
 }

If the enum is internal to the same package, the error will not be reported. The @internal restriction only applies to cross-package usage.

How to ignore this error #

You can use the identifier return.internalEnum to ignore this error using a comment:

// @phpstan-ignore return.internalEnum
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: return.internalEnum

Rules that report this error #

  • PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]
Theme
A
© 2026 PHPStan s.r.o.