Menu

← Back to staticMethod.*

Error Identifier: staticMethod.internal

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 ThirdParty\Foo;

// ThirdParty\Foo has:
// /** @internal */
// public static function doInternal(): void {}

Foo::doInternal();

Why is it reported? #

A static method marked as @internal is being called from outside its root namespace. Internal methods are not part of the public API of the package and may change or be removed at any time without following semantic versioning. Calling them from external code creates a fragile dependency.

How to fix it #

Use the public API provided by the package instead:

 namespace App;

 use ThirdParty\Foo;

-Foo::doInternal();
+Foo::doPublicAlternative();

If the method is internal to the same package, the error will not be reported. The @internal restriction only applies to cross-package usage (calls from outside the root namespace).

How to ignore this error #

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

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

Rules that report this error #

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

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.