Menu
Error Identifier: methodTag.internalTrait
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\InternalTrait;
/**
* @method InternalTrait getTrait()
*/
class Service
{
}
Why is it reported? #
A @method PHPDoc tag references a trait marked with the @internal tag from another package. Internal traits 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.
How to fix it #
Replace the internal trait type reference with a public API type:
<?php declare(strict_types = 1);
/**
- * @method InternalTrait getTrait()
+ * @method PublicInterface getTrait()
*/
class Service
{
}
How to ignore this error #
You can use the identifier methodTag.internalTrait to ignore this error using a comment:
// @phpstan-ignore methodTag.internalTrait
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: methodTag.internalTrait
Rules that report this error #
- PHPStan\Rules\InternalTag\RestrictedInternalClassNameUsageExtension [1]