Error Identifier: requireExtends.duplicate
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);
/**
* @phpstan-require-extends Base
* @phpstan-require-extends AnotherBase
*/
interface Constrainable
{
}
Why is it reported? #
The @phpstan-require-extends PHPDoc tag is used more than once on the same interface or trait. Since a class can only extend one parent class, there can only be one @phpstan-require-extends constraint. Having multiple tags is contradictory because a class cannot extend two different classes at the same time.
How to fix it #
Keep only one @phpstan-require-extends tag:
<?php declare(strict_types = 1);
/**
* @phpstan-require-extends Base
- * @phpstan-require-extends AnotherBase
*/
interface Constrainable
{
}
How to ignore this error #
You can use the identifier requireExtends.duplicate to ignore this error using a comment:
// @phpstan-ignore requireExtends.duplicate
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: requireExtends.duplicate