-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
RFC: Add #[\Deprecated]
Attribute
#11293
Conversation
Please update RFC with link to this PR |
@beberlei, is there any chance to include a It can be used by PhpStorm, @rectorphp, and other tools in the ecosystem to simplify migration for end users. |
@pronskiy I can add it as a secondary vote, if i ever get around to finish the RFC for it. But it would be an essentially "useless" property from the engine POV that would be only useful for IDEs, and then without a standard, prone to conflicts. |
@beberlei, how about adding a generic parameter? And letting tools to decide on the standard/convention, should there be one. #[Attribute(Attribute::TARGET_METHOD|Attribute::TARGET_FUNCTION)]
final class Deprecated
{
public function __construct(?string $message = null, ...$extra) {}
}
#[Deprecated('Message', replacement: 'bar')]
foo(); |
Well, giving it another thought, tools could just have their own attribute #[
Deprecated('Message'),
Replacement('bar'),
]
foo(); |
@beberlei Is there a specific reason #[Deprecated] is only targeting functions? Why not classes, so that any reference of the class, be it instantiation, or static access, emits the deprecation? |
@bwoebi no, i didnt get to this part yet due to my lack of engine skills :) |
Hello, As a small lib maintainer I like this idea. At the moment I use PHPDoc + |
0721ddc
to
8911162
Compare
@bwoebi Constants do not (yet) support attributes. |
4613757
to
7109dea
Compare
#[Deprecated]
attribute#[\Deprecated]
attribute
7dcafb2
to
ce49812
Compare
#[\Deprecated]
attribute#[\Deprecated]
Attribute
Unfortunately, I'm unable to reproduce the ARM build failures. The tests within a Debian Docker container on a aarch64 VM appear to succeed:
|
On my ARM Mac these also pass with |
@TimWolla This is likely related to the |
Thanks, this reproduces the issue for me on x64 Linux:
JIT is required. |
Now merged, thank you all for the review and assistance. The follow-up PR to apply the Attribute is here: #14750 |
RFC: https://wiki.php.net/rfc/deprecated_attribute
I made a mistake rebasing the previous PR #6521 and had to create this new one. Additional work is necessary to adapt this to new APIs and to move over the discussion and suggestions.
ToDo: