Menu

← Back to staticMethod.*

Error Identifier: staticMethod.internalEnum

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

// In package vendor/some-library:

namespace SomeLibrary;

/** @internal */
enum InternalStatus: string
{
	case Active = 'active';

	public static function default(): self
	{
		return self::Active;
	}
}
<?php declare(strict_types = 1);

// In your code:

namespace App;

use SomeLibrary\InternalStatus;

$status = InternalStatus::default();

Why is it reported? #

A static method is being called on an enum that is marked as @internal. Internal enums are not part of the public API of the package that defines them and may change or be removed without notice. Calling static methods on them creates a dependency on implementation details.

This error can be triggered by accessing the enum class itself (which is internal) or by calling an internal static method on an enum.

How to fix it #

Use the public API of the package instead of calling static methods on internal enums:

 namespace App;

-use SomeLibrary\InternalStatus;
+use SomeLibrary\Status;

-$status = InternalStatus::default();
+$status = Status::default();

If the enum is internal to your own project and the usage is within the same root namespace, the error will not be reported.

How to ignore this error #

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

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

Rules that report this error #

  • PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]
  • PHPStan\Rules\InternalTag\RestrictedInternalMethodUsageExtension [1] [2]

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.