Error Identifier: requireExtends.deprecatedInterface
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 reported by the phpstan-deprecation-rules extension.
Code example #
<?php declare(strict_types = 1);
/** @deprecated Use NewInterface instead */
interface OldInterface
{
}
/**
* @phpstan-require-extends OldInterface
*/
trait MyTrait
{
}
Why is it reported? #
The @phpstan-require-extends PHPDoc tag references an interface that has been marked as @deprecated. Using a deprecated interface in a require-extends constraint means that any class using this trait would be required to extend a deprecated interface, which should be avoided.
How to fix it #
Update the @phpstan-require-extends tag to reference the non-deprecated replacement:
/**
- * @phpstan-require-extends OldInterface
+ * @phpstan-require-extends NewInterface
*/
trait MyTrait
{
}
How to ignore this error #
You can use the identifier requireExtends.deprecatedInterface to ignore this error using a comment:
// @phpstan-ignore requireExtends.deprecatedInterface
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.deprecatedInterface
Rules that report this error #
- PHPStan\Rules\Deprecations\RestrictedDeprecatedClassNameUsageExtension [1] phpstan/phpstan-deprecation-rules