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.
This error is not likely to ever be reported in practice. The identifier exists because of an entirely theoretical possible combination of inputs when calling
RuleErrorBuilder::identifier().
Code example #
<?php declare(strict_types = 1);
interface Loggable
{
}
/**
* @phpstan-require-implements Loggable
*/
class MyClass
{
}
Why is it reported? #
The @phpstan-require-implements PHPDoc tag is used on a class, interface, or enum instead of a trait. This tag is only valid on traits, where it restricts which classes can use the trait by requiring them to implement a specific interface.
How to fix it #
Move the tag to a trait, or use implements directly:
<?php declare(strict_types = 1);
interface Loggable
{
}
-/**
- * @phpstan-require-implements Loggable
- */
-class MyClass
+class MyClass implements Loggable
{
}
How to ignore this error #
You can use the identifier requireImplements.onTrait to ignore this error using a comment:
// @phpstan-ignore requireImplements.onTrait
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: requireImplements.onTrait
Rules that report this error #
- PHPStan\Rules\PhpDoc\RequireImplementsDefinitionClassRule [1]