Menu
Error Identifier: staticProperty.deprecatedClass
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 NewConfig instead */
class OldConfig
{
public static string $value = 'default';
}
echo OldConfig::$value;
Why is it reported? #
This error is reported by the phpstan-deprecation-rules extension.
A static property is accessed on a class that is marked as @deprecated. Deprecated classes are planned for removal in a future version, and code should not rely on them.
How to fix it #
Use the recommended replacement class:
<?php declare(strict_types = 1);
-echo OldConfig::$value;
+echo NewConfig::$value;
How to ignore this error #
You can use the identifier staticProperty.deprecatedClass to ignore this error using a comment:
// @phpstan-ignore staticProperty.deprecatedClass
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: staticProperty.deprecatedClass