Error Identifier: phpstanApi.trait
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);
// When a PHPStan extension uses a PHPStan internal trait:
use PHPStan\SomeInternalTrait;
class MyExtension
{
use SomeInternalTrait;
}
Why is it reported? #
The code uses a PHPStan trait that is not marked with the @api tag. Traits without the @api tag are internal to PHPStan and are not covered by the backward compatibility promise. They may change or be removed in minor PHPStan versions without notice.
How to fix it #
Use only @api-tagged PHPStan types in your extensions. If you believe the trait should be part of the public API, you can open a discussion at github.com/phpstan/phpstan/discussions.
See also: Backward Compatibility Promise
How to ignore this error #
You can use the identifier phpstanApi.trait to ignore this error using a comment:
// @phpstan-ignore phpstanApi.trait
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: phpstanApi.trait