@@ -36,3 +36,48 @@ In case you don't own the code which you want to be considered deprecated, use [
36
36
/** @deprecated */
37
37
class ThirdPartyClass {}
38
38
```
39
+
40
+
41
+
## Custom deprecated scopes
42
+
43
+
Usage of deprecated code is not reported in code that is also deprecated:
44
+
45
+
```php
46
+
/** @deprecated */
47
+
function doFoo(): void
48
+
{
49
+
// not reported:
50
+
anotherDeprecatedFunction();
51
+
}
52
+
```
53
+
54
+
If you have [a different way](https://.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://.com/phpstan/phpstan-deprecation-rules/blob/1.1.x/src/Rules/Deprecations/DeprecatedScopeResolver.php) interface.
55
+
56
+
For example if you mark your PHPUnit tests that test deprecated code with `@group legacy`, you can implement the extension this way:
57
+
58
+
```php
59
+
class GroupLegacyScopeResolver implements DeprecatedScopeResolver
60
+
{
61
+
62
+
public function isScopeDeprecated(Scope $scope): bool
0 commit comments