phpstan/phpstan-deprecation-rules
Install the package via Composer as a development dependency:
composer require --dev phpstan/phpstan-deprecation-rules
If you use phpstan/extension-installer, the rules are auto-configured. Otherwise, manually include vendor/phpstan/phpstan-deprecation-rules/rules.neon in your PHPStan config (phpstan.neon). Run vendor/bin/phpstan analyse — the extension will now catch all usages of deprecated classes, methods, properties, constants, and traits annotated with @deprecated.
@deprecated on external classes/methods (e.g., in stubs/). Place stubs in your repo and reference them via parameters.stubsDir in config.@group legacy and implement a custom DeprecatedScopeResolver to exclude those scopes from warnings.#[Deprecated(reason: '…')]) and implement a DeprecationRuleExtension to register custom deprecation detection.@deprecated) — this prevents noise when maintaining legacy code.*Restricted*Extension classes (e.g., RestrictedMethodUsageExtension), meaning method, property, and constant deprecations now share logic — ensure you’re using the latest version to benefit from fixes.Scope->getPhpVersion() — align your phpVersion setting in phpstan.neon with your target environment.stubsDir is set and stubs include all relevant symbols (missing annotations won’t be caught).DeprecatedScopeResolver interface is your main extension point for custom logic — combine it with @group annotations, custom docblocks, or symfony/contracts-style #[Deprecated] to scale adoption.How can I help you explore Laravel packages today?