Menu

← Back to method.*

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

use Acme\Library\InternalHelper;

$helper = new InternalHelper();
$helper->processInternal(); // Method is @internal

Why is it reported? #

A method marked with the @internal PHPDoc tag is being called from outside its allowed scope. Internal methods are implementation details that are not part of the public API. They may change or be removed without notice in future versions, and calling them from external code creates fragile dependencies.

How to fix it #

Use the public API of the class instead of calling its internal methods. Check the class documentation for the intended way to achieve the same result.

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

 use Acme\Library\InternalHelper;

 $helper = new InternalHelper();
-$helper->processInternal();
+$helper->process();

How to ignore this error #

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

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

Rules that report this error #

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

Edit this page on GitHub

Theme
A
© 2026 PHPStan s.r.o.