Skip to content

Remove DeprecatedAnnotationToDeprecatedAttributeRector from PHP 8.4 set - #8326

Merged
TomasVotruba merged 2 commits into
mainfrom
remove-deprecated-annotation-to-attribute-from-php84
Aug 9, 2026
Merged

Remove DeprecatedAnnotationToDeprecatedAttributeRector from PHP 8.4 set#8326
TomasVotruba merged 2 commits into
mainfrom
remove-deprecated-annotation-to-attribute-from-php84

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

DeprecatedAnnotationToDeprecatedAttributeRector changes a doc annotation into a runtime attribute:

 final class SomeClass
 {
     /**
      * @deprecated 1.0 Use SomeOtherClass instead
      */
+    #[\Deprecated(message: 'Use SomeOtherClass instead', since: '1.0')]
     public function oldMethod()
     {
     }
 }

#[\Deprecated] makes PHP emit an E_USER_DEPRECATED on every call. So a comment that only informed the reader now produces runtime noise, and in projects that convert deprecations to exceptions it breaks the test suite.

That is not what a PHP 8.4 upgrade is usually about, so the rule is removed from the php84 set. It stays available to register manually, and it stays in the php-polyfills set where the opt-in is explicit.

The rule turns a `@deprecated` annotation into a `#[\Deprecated]` attribute,
which escalates a documentation hint into a runtime deprecation warning.
That is rarely the intent when upgrading to PHP 8.4, so the rule should be
opt-in instead of part of the set.
@TomasVotruba
TomasVotruba enabled auto-merge (squash) August 9, 2026 11:50
@TomasVotruba
TomasVotruba merged commit d43a698 into main Aug 9, 2026
64 checks passed
@TomasVotruba
TomasVotruba deleted the remove-deprecated-annotation-to-attribute-from-php84 branch August 9, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant