Skip to content

Conversation

@peterfox
Copy link
Contributor

Changes

  • Adds a new DeprecatedAnnotationToDeprecatedAttributeRector rule
  • Adds tests for DeprecatedAnnotationToDeprecatedAttributeRector
  • Adds DeprecatedAnnotationToDeprecatedAttributeRector to the PHP 84 config
  • Adds the DEPRECATED_ATTRIBUTE constant

Why

Pretty self explanatory. This just moves the annotation to an attribute as is the case for a lot of things in the PHP world now. The attribute was added in PHP 8.4.

-/**
-* @deprecated 1.0.0 Use SomeOtherClass instead
-*/
+#[\Deprecated(message: 'Use SomeOtherClass instead', since: 1.0.0)]
class SomeClass
{
}

@TomasVotruba
Copy link
Member

TomasVotruba commented May 23, 2025

Thanks Peter 👍

How is the attribute supporting doing in PHPStan https://github.com/phpstan/phpstan-deprecation-rules ?
How's the PHPStorm support for in-code feedback?

We don't want to break those 2, as that's the main benefit of @deprecated in the code.

@peterfox
Copy link
Contributor Author

Thanks Peter 👍

How is the attribute supporting doing in PHPStan https://github.com/phpstan/phpstan-deprecation-rules ? How's the PHPStorm support for in-code feedback?

We don't want to break those 2, as that's the main benefit of @deprecated in the code.

@TomasVotruba it appears I got a head of myself 😓 PHPStan doesn't seem to support it, nor does PHPStorm.

Equally only till testing it more did I realise that the attribute only works with Functions/Class Methods/Constants, so it's a bit poor compared to the annotation.

Happy to shelve this PR until the attribute is more useful.

peterfox and others added 2 commits May 25, 2025 13:55
…ibuteRector.php

Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
@peterfox peterfox requested a review from samsonasik May 28, 2025 20:45
@TomasVotruba TomasVotruba merged commit 8874702 into rectorphp:main May 28, 2025
45 checks passed
@TomasVotruba
Copy link
Member

TomasVotruba commented May 28, 2025

Thank you Peter 🥳 Let's ship it

DanielEScherzer added a commit to DanielEScherzer/rector-src that referenced this pull request Aug 20, 2025
DanielEScherzer added a commit to DanielEScherzer/rector-src that referenced this pull request Aug 20, 2025
DanielEScherzer added a commit to DanielEScherzer/rector-src that referenced this pull request Aug 20, 2025
Based on the PHP 8.4 rule from rectorphp#6923, logic was moved to a new
`DeprecatedAnnotationToDeprecatedAttributeConverter` service to avoid
duplication.
DanielEScherzer added a commit to DanielEScherzer/rector-src that referenced this pull request Aug 20, 2025
Based on the PHP 8.4 rule from rectorphp#6923, logic was moved to a new
`DeprecatedAnnotationToDeprecatedAttributeConverter` service to avoid
duplication.
samsonasik pushed a commit that referenced this pull request Aug 20, 2025
Based on the PHP 8.4 rule from #6923, logic was moved to a new
`DeprecatedAnnotationToDeprecatedAttributeConverter` service to avoid
duplication.
@github-actions
Copy link
Contributor

This pull request has been automatically locked because it has been closed for 150 days. Please open a new PR if you want to continue the work.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants