You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: deprecated attribute support and compatibility matrix
Cover PHP 8.4 native #[\Deprecated] attribute detection (via the extension, not PHPStan core) and add a compatibility table summarising which mechanisms emit a runtime deprecation and which are caught by PHPStan.
|`@deprecated` PHPDoc | No | Yes — via this extension |
35
+
|`#[\Deprecated]`, [since PHP 8.4](https://www.php.net/manual/en/class.deprecated.php)| Yes | Yes — via this extension |
36
+
|`trigger_deprecation()`| Yes | No |
37
+
30
38
## Deprecating code you don't own
31
39
32
40
This extension emits deprecation warnings on code, which uses properties/functions/methods/classes which are annotated as `@deprecated`.
@@ -37,6 +45,22 @@ In case you don't own the code which you want to be considered deprecated, use [
37
45
class ThirdPartyClass {}
38
46
```
39
47
48
+
## `#[\Deprecated]` attribute (Since PHP 8.4)
49
+
50
+
PHP 8.4 introduced a native [`#[\Deprecated]`](https://wiki.php.net/rfc/deprecated_attribute) attribute that triggers a runtime deprecation notice when a symbol is called.
51
+
52
+
**This extension detects it** — no `@deprecated` PHPDoc annotation is required alongside it:
53
+
54
+
```php
55
+
#[\Deprecated('Will be removed in 2.0, use constructor injection instead.')]
56
+
public function __construct(...) {}
57
+
```
58
+
59
+
PHPStan will report call sites with the `method.deprecated` identifier, including the attribute's description string.
60
+
61
+
> [!NOTE]
62
+
> Detection of `#[\Deprecated]` is provided by this extension (`phpstan-deprecation-rules`), **not** by PHPStan core. Removing this extension silences those errors entirely.
63
+
40
64
## Custom deprecation markers
41
65
42
66
You can implement extensions to support even e.g. custom `#[MyDeprecated]` attribute. [Learn more](https://phpstan.org/developing-extensions/custom-deprecations).
0 commit comments