Menu

← Back to method.*

Error Identifier: method.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);

namespace App;

use Vendor\Internal\Status;

function doFoo(Status $status): void
{
	$status->label(); // ERROR: Call to method label() of internal enum Vendor\Internal\Status from outside its root namespace Vendor.
}

Why is it reported? #

A method is being called on an object whose type is an enum marked as @internal. Internal enums are not part of the public API and are intended to be used only within the package or namespace where they are defined. Calling methods on an internal enum from outside its root namespace violates this contract. The enum may change or be removed without notice in future versions of the package.

How to fix it #

Use the public API provided by the package instead of accessing internal enums directly:

 <?php declare(strict_types = 1);
 
 namespace App;

-use Vendor\Internal\Status;
+use Vendor\PublicStatus;

-function doFoo(Status $status): void
+function doFoo(PublicStatus $status): void
 {
 	$status->label();
 }

If no public alternative exists, consider reaching out to the package maintainers to request a public API for the functionality needed.

How to ignore this error #

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

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

Rules that report this error #

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

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.