Menu
Error Identifier: constant.deprecated
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 phpstan/phpstan-deprecation-rules.
Code example #
<?php declare(strict_types = 1);
/**
* @deprecated Use NEW_LIMIT instead.
*/
define('OLD_LIMIT', 100);
echo OLD_LIMIT;
Why is it reported? #
The code uses a constant that has been marked as deprecated via a @deprecated PHPDoc tag. Deprecated constants are planned for removal in a future version and should no longer be relied upon.
How to fix it #
Replace the deprecated constant with its recommended replacement:
<?php declare(strict_types = 1);
-echo OLD_LIMIT;
+echo NEW_LIMIT;
How to ignore this error #
You can use the identifier constant.deprecated to ignore this error using a comment:
// @phpstan-ignore constant.deprecated
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: constant.deprecated
Rules that report this error #
- PHPStan\Rules\Deprecations\FetchingDeprecatedConstRule [1] phpstan/phpstan-deprecation-rules