Menu

← Back to staticMethod.*

Error Identifier: staticMethod.internalClass

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 Internal\CacheDriver;

$data = CacheDriver::getAll();

Why is it reported? #

A static method is being called on a class that is marked as @internal. Internal classes are not meant to be used outside of their own package, and calling methods on them creates a dependency on an implementation detail that can change at any time without following semantic versioning.

How to fix it #

Use the public API provided by the package instead of accessing internal classes directly.

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

-use Internal\CacheDriver;
+use Public\Cache;

-$data = CacheDriver::getAll();
+$data = Cache::getAll();

How to ignore this error #

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

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

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.