Error Identifier: parameter.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 Acme\Library\InternalHelper;
function process(InternalHelper $helper): void
{
}
Why is it reported? #
A function or method parameter uses a class marked with the @internal tag from another package as its type declaration. Internal classes are implementation details of the library and are not part of its public API. They may change or be removed in future versions without notice. Using an internal class as a parameter type creates a dependency on an unstable API.
How to fix it #
Replace the internal class with a public API type, such as an interface or a non-internal class:
<?php declare(strict_types = 1);
namespace App;
-use Acme\Library\InternalHelper;
+use Acme\Library\HelperInterface;
-function process(InternalHelper $helper): void
+function process(HelperInterface $helper): void
{
}
How to ignore this error #
You can use the identifier parameter.internalClass to ignore this error using a comment:
// @phpstan-ignore parameter.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: parameter.internalClass
Rules that report this error #
- PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]