PHPackages                             phpstan/phpstan-deprecation-rules - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. phpstan/phpstan-deprecation-rules

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

phpstan/phpstan-deprecation-rules
=================================

PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.

2.0.4(4mo ago)45689.0M↓10.1%25[17 issues](https://github.com/phpstan/phpstan-deprecation-rules/issues)[6 PRs](https://github.com/phpstan/phpstan-deprecation-rules/pulls)20MITPHPPHP ^7.4 || ^8.0CI passing

Since Jun 24Pushed 3d ago5 watchersCompare

[ Source](https://github.com/phpstan/phpstan-deprecation-rules)[ Packagist](https://packagist.org/packages/phpstan/phpstan-deprecation-rules)[ RSS](/packages/phpstan-phpstan-deprecation-rules/feed)WikiDiscussions 2.0.x Synced 2d ago

READMEChangelog (10)Dependencies (4)Versions (38)Used By (20)

Rules for detecting usage of deprecated classes, methods, properties, constants and traits.
===========================================================================================

[](#rules-for-detecting-usage-of-deprecated-classes-methods-properties-constants-and-traits)

[![Build](https://github.com/phpstan/phpstan-deprecation-rules/workflows/Build/badge.svg)](https://github.com/phpstan/phpstan-deprecation-rules/actions)[![Latest Stable Version](https://camo.githubusercontent.com/9778fecb7103b169aaba239a9c523115df5ae99fc173a7a137e134034bd94279/68747470733a2f2f706f7365722e707567782e6f72672f7068707374616e2f7068707374616e2d6465707265636174696f6e2d72756c65732f762f737461626c65)](https://packagist.org/packages/phpstan/phpstan-deprecation-rules)[![License](https://camo.githubusercontent.com/9e83f095b59116d92f871fd56d8dd813d73cf8570219893dcb611e62a5b4e913/68747470733a2f2f706f7365722e707567782e6f72672f7068707374616e2f7068707374616e2d6465707265636174696f6e2d72756c65732f6c6963656e7365)](https://packagist.org/packages/phpstan/phpstan-deprecation-rules)

- [PHPStan](https://phpstan.org/)

Installation
------------

[](#installation)

To use this extension, require it in [Composer](https://getcomposer.org/):

```
composer require --dev phpstan/phpstan-deprecation-rules

```

If you also install [phpstan/extension-installer](https://github.com/phpstan/extension-installer) then you're all set!

 Manual installationIf you don't want to use `phpstan/extension-installer`, include rules.neon in your project's PHPStan config:

```
includes:
    - vendor/phpstan/phpstan-deprecation-rules/rules.neon

```

Deprecating code you don't own
------------------------------

[](#deprecating-code-you-dont-own)

This extension emits deprecation warnings on code, which uses properties/functions/methods/classes which are annotated as `@deprecated`.

In case you don't own the code which you want to be considered deprecated, use [PHPStan Stub Files](https://phpstan.org/user-guide/stub-files) to declare deprecations for vendor files like:

```
/** @deprecated */
class ThirdPartyClass {}

```

Custom deprecation markers
--------------------------

[](#custom-deprecation-markers)

You can implement extensions to support even e.g. custom `#[MyDeprecated]` attribute. [Learn more](https://phpstan.org/developing-extensions/custom-deprecations).

Custom deprecated scopes
------------------------

[](#custom-deprecated-scopes)

Usage of deprecated code is not reported in code that is also deprecated:

```
/** @deprecated */
function doFoo(): void
{
    // not reported:
    anotherDeprecatedFunction();
}
```

If you have [a different way](https://github.com/phpstan/phpstan-deprecation-rules/issues/64) of marking code that calls deprecated symbols on purpose and you don't want these calls to be reported either, you can write an extension by implementing the [`DeprecatedScopeResolver`](https://github.com/phpstan/phpstan-deprecation-rules/blob/1.1.x/src/Rules/Deprecations/DeprecatedScopeResolver.php) interface.

For example if you mark your PHPUnit tests that test deprecated code with `@group legacy`, you can implement the extension this way:

```
class GroupLegacyScopeResolver implements DeprecatedScopeResolver
{

	public function isScopeDeprecated(Scope $scope): bool
	{
		$function = $scope->getFunction();
		return $function !== null
			&& $function->getDocComment() !== null
			&& strpos($function->getDocComment(), '@group legacy') !== false;
	}

}
```

And register it in your [configuration file](https://phpstan.org/config-reference):

```
services:
	-
		class: GroupLegacyScopeResolver
		tags:
			- phpstan.deprecations.deprecatedScopeResolver
```

[Learn more about Scope](https://phpstan.org/developing-extensions/scope), a core concept for implementing custom PHPStan extensions.

###  Health Score

76

—

ExcellentBetter than 100% of packages

Maintenance88

Actively maintained with recent releases

Popularity72

Solid adoption and visibility

Community56

Growing community involvement

Maturity80

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~104 days

Recently: every ~144 days

Total

29

Last Release

4d ago

Major Versions

0.12.6 → 1.0.02021-09-23

1.2.x-dev → 2.0.02024-10-26

PHP version history (4 changes)0.10PHP ~7.1

0.12.5PHP ^7.1 || ^8.0

1.1.0PHP ^7.2 || ^8.0

2.0.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/104888?v=4)[Ondřej Mirtes](/maintainers/ondrejmirtes)[@ondrejmirtes](https://github.com/ondrejmirtes)

---

Top Contributors

[![ondrejmirtes](https://avatars.githubusercontent.com/u/104888?v=4)](https://github.com/ondrejmirtes "ondrejmirtes (97 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (22 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (13 commits)")[![iluuu1994](https://avatars.githubusercontent.com/u/1752683?v=4)](https://github.com/iluuu1994 "iluuu1994 (11 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (11 commits)")[![renovate-bot](https://avatars.githubusercontent.com/u/25180681?v=4)](https://github.com/renovate-bot "renovate-bot (10 commits)")[![paxal](https://avatars.githubusercontent.com/u/1848817?v=4)](https://github.com/paxal "paxal (9 commits)")[![ruudk](https://avatars.githubusercontent.com/u/104180?v=4)](https://github.com/ruudk "ruudk (5 commits)")[![cs278](https://avatars.githubusercontent.com/u/17377?v=4)](https://github.com/cs278 "cs278 (4 commits)")[![villfa](https://avatars.githubusercontent.com/u/2891564?v=4)](https://github.com/villfa "villfa (3 commits)")[![herndlm](https://avatars.githubusercontent.com/u/5738896?v=4)](https://github.com/herndlm "herndlm (2 commits)")[![Khartir](https://avatars.githubusercontent.com/u/5592420?v=4)](https://github.com/Khartir "Khartir (2 commits)")[![Kocal](https://avatars.githubusercontent.com/u/2103975?v=4)](https://github.com/Kocal "Kocal (2 commits)")[![eiriksm](https://avatars.githubusercontent.com/u/865153?v=4)](https://github.com/eiriksm "eiriksm (1 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![clxmstaab](https://avatars.githubusercontent.com/u/47448731?v=4)](https://github.com/clxmstaab "clxmstaab (1 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (1 commits)")[![step-security-bot](https://avatars.githubusercontent.com/u/89328645?v=4)](https://github.com/step-security-bot "step-security-bot (1 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (1 commits)")[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (1 commits)")

---

Tags

deprecationsphpphp7phpstanstatic-analysisstatic-code-analysisstatic analysis

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpstan-phpstan-deprecation-rules/health.svg)

```
[![Health](https://phpackages.com/badges/phpstan-phpstan-deprecation-rules/health.svg)](https://phpackages.com/packages/phpstan-phpstan-deprecation-rules)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.5k55.4M8.4k](/packages/larastan-larastan)[phpstan/phpstan-symfony

Symfony Framework extensions and rules for PHPStan

79475.7M2.2k](/packages/phpstan-phpstan-symfony)[phpstan/phpstan-doctrine

Doctrine extensions for PHPStan

67272.8M1.4k](/packages/phpstan-phpstan-doctrine)[shipmonk/dead-code-detector

Dead code detector to find unused PHP code via PHPStan extension. Can automatically remove dead PHP code. Supports libraries like Symfony, Doctrine, PHPUnit etc. Detects dead cycles. Can detect dead code that is tested.

4853.5M91](/packages/shipmonk-dead-code-detector)[phpstan/phpstan-strict-rules

Extra strict and opinionated rules for PHPStan

70370.0M5.3k](/packages/phpstan-phpstan-strict-rules)[phpstan/phpstan-phpunit

PHPUnit extensions and rules for PHPStan

533113.2M11.6k](/packages/phpstan-phpstan-phpunit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
