8000 [PHP84] Deprecated annotation to Deprecated attribute by peterfox · Pull Request #6923 · rectorphp/rector-src · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[PHP84] Deprecated annotation to Deprecated attribute #6923

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
May 28, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0