Skip to content

Commit 2821c81

Browse files
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.
1 parent 945df12 commit 2821c81

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ includes:
2727
```
2828
</details>
2929

30+
## Compatibility with deprecation mechanisms
31+
32+
| Mechanism | Emits runtime deprecation | Supported by PHPStan? |
33+
|---------------------------------------------------------------------------------------|---------------------------|--------------------------|
34+
| `@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+
3038
## Deprecating code you don't own
3139

3240
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 [
3745
class ThirdPartyClass {}
3846
```
3947

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+
4064
## Custom deprecation markers
4165

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

0 commit comments

Comments
 (0)