Error Identifier: class.implementsDeprecatedClass
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);
/** @deprecated Use NewInterface instead */
interface OldInterface
{
}
class Foo implements OldInterface // reported
{
}
Why is it reported? #
The class in the implements clause is marked as @deprecated. Deprecated symbols are scheduled for removal in a future version, and new code should not rely on them. Continuing to implement a deprecated interface means the code will need to be updated when the deprecated symbol is removed.
This error is reported by the phpstan-deprecation-rules package.
How to fix it #
Replace the deprecated interface with its suggested replacement, if one is provided in the deprecation message.
-class Foo implements OldInterface
+class Foo implements NewInterface
{
}
How to ignore this error #
You can use the identifier class.implementsDeprecatedClass to ignore this error using a comment:
// @phpstan-ignore class.implementsDeprecatedClass
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: class.implementsDeprecatedClass
Rules that report this error #
- PHPStan\Rules\Deprecations\RestrictedDeprecatedClassNameUsageExtension [1] phpstan/phpstan-deprecation-rules