Skip to content

[RFC] Deprecate most of or all annotations? #49369

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

Closed
alexislefebvre opened this issue Feb 14, 2023 · 6 comments
Closed

[RFC] Deprecate most of or all annotations? #49369

alexislefebvre opened this issue Feb 14, 2023 · 6 comments
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)

Comments

@alexislefebvre
Copy link
Contributor

alexislefebvre commented Feb 14, 2023

Description

There is ongoing work about deprecating the usage of annotations:

I didn't see a general discussion about this subject, so I created this issue to raise the question:

Should some or all annotations be deprecated in 6.3 and removed in 7.0?

Attributes are natively supported with Symfony 6.3+, because it requires PHP ≥ 8.1 and attributes were added in PHP 8.0. While annotations require to install doctrine/annotations.

On a side note, PHPUnit 10 allow to use attributes instead of annotations: sebastianbergmann/phpunit#4502

Example

-    /**
-     * @required
-     */
+    #[\Symfony\Contracts\Service\Attribute\Required]
     public function setFoo(Foo $foo)
     {
         // should be called
     }
@carsonbot carsonbot added the RFC RFC = Request For Comments (proposals about features that you want to be discussed) label Feb 14, 2023
@derrabus
Copy link
Member

Yes. Let's kill Doctrine Annotations.

@stof
Copy link
Member

stof commented Apr 21, 2023

Knowing that the Rector implementation of migrating annotations to attributes is currently broken (because their parsing of Doctrine annotations is broken, ignoring the fact that string literals are a thing in annotations and quotes are not just a parenthesis-like delimiter), there is no easy working migration path for now.

@yguedidi
Copy link
Contributor

@stof there is a work in progress to fix that: rectorphp/rector-src#3645

@alexislefebvre
Copy link
Contributor Author

@derrabus Thanks for the update! Is there still some annotations that are not (yet) deprecated?

@derrabus
Copy link
Member

No, it's done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC RFC = Request For Comments (proposals about features that you want to be discussed)
Projects
None yet
Development

No branches or pull requests

5 participants