Skip to content
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

Deprecate annotations support #2772

Merged
merged 5 commits into from
Jun 24, 2024

Conversation

mbabker
Copy link
Contributor

@mbabker mbabker commented Feb 19, 2024

Now that the hard dependency is broken, the next major task to coincide with the doctrine/annotations library being deprecated would be deprecating annotations support in this package. WIP for now because this is going to be quite a big deprecation and architectural task since the attribute drivers are all subclasses of their annotation counterparts so some thought will be needed into how to address that (as folks in the Symfony ecosystem will eventually come here with reports about it, even with the drivers all being flagged internal).

Other things to think about along the way include:

  • In Symfony, the term "annotation" was deprecated in full and replaced with "attribute" in all relevant APIs, which included renaming and aliasing classes in "Annotation" namespaces and renaming methods (i.e. setAnnotationReader()), how in-depth does this deprecation need to go here?

Copy link

codecov bot commented Feb 19, 2024

Codecov Report

Attention: Patch coverage is 80.71279% with 92 lines in your changes missing coverage. Please review.

Project coverage is 78.85%. Comparing base (0632ab1) to head (6e633fa).
Report is 50 commits behind head on main.

Files Patch % Lines
src/Tree/Mapping/Driver/Attribute.php 76.00% 24 Missing ⚠️
src/Sluggable/Mapping/Driver/Attribute.php 78.12% 14 Missing ⚠️
src/Loggable/Mapping/Driver/Attribute.php 79.06% 9 Missing ⚠️
src/Mapping/ExtensionMetadataFactory.php 63.15% 7 Missing ⚠️
src/Translatable/Mapping/Driver/Attribute.php 83.72% 7 Missing ⚠️
src/Blameable/Mapping/Driver/Attribute.php 80.00% 6 Missing ⚠️
src/IpTraceable/Mapping/Driver/Attribute.php 77.77% 6 Missing ⚠️
src/Timestampable/Mapping/Driver/Attribute.php 81.48% 5 Missing ⚠️
src/Sortable/Mapping/Driver/Attribute.php 83.33% 4 Missing ⚠️
src/Mapping/Driver/AbstractAnnotationDriver.php 72.72% 3 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2772      +/-   ##
==========================================
+ Coverage   78.75%   78.85%   +0.10%     
==========================================
  Files         163      167       +4     
  Lines        8593     8640      +47     
==========================================
+ Hits         6767     6813      +46     
- Misses       1826     1827       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@franmomu
Copy link
Collaborator

I don't know if we can invert the inheritance and make the Annotation classes inherit from the Attribute ones

@mbabker
Copy link
Contributor Author

mbabker commented Feb 19, 2024

I don't know if we can invert the inheritance and make the Annotation classes inherit from the Attribute ones

We'd have to flip it for the AnnotationDriverInterface and AttributeDriverInterface as well. There are checks like this one targeting only the attribute drivers so those bits and bobs would need to be inverted as well to not break any other behaviors.

Conceivably it's possible, and the mapping drivers within this package are a lot more of an internal implementation than in the object managers themselves given the way ExtensionMetadataFactory::getDriver() works, so even though there are some potential B/C implications they aren't as impactful to downstream users as the changes that were made upstream.

@mbabker mbabker force-pushed the deprecate-annotations branch 3 times, most recently from 6489401 to 8a86f5e Compare February 19, 2024 23:53
@mbabker
Copy link
Contributor Author

mbabker commented Feb 20, 2024

Reversing the inheritance chain actually worked out a lot more smoothly than I expected it to. The only possible hangup from an end-user perspective is if someone implemented a custom extension (as in fully added their own listener extending from MappedEventSubscriber and adding their own annotation/attribute mapping drivers), they would also have to flip their inheritance chains. I would suggest the likelihood of that is pretty low, though.

@franmomu
Copy link
Collaborator

franmomu commented Jun 9, 2024

Reversing the inheritance chain actually worked out a lot more smoothly than I expected it to.

nice 🎉

The only possible hangup from an end-user perspective is if someone implemented a custom extension (as in fully added their own listener extending from MappedEventSubscriber and adding their own annotation/attribute mapping drivers), they would also have to flip their inheritance chains. I would suggest the likelihood of that is pretty low, though.

I'm fine with this, I don't think a lot of people would have both annotations and attributes drivers in their custom extensions.

@mbabker mbabker marked this pull request as ready for review June 9, 2024 16:01
@mbabker mbabker changed the title [WIP] Deprecate annotations support Deprecate annotations support Jun 9, 2024
Copy link
Collaborator

@franmomu franmomu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@franmomu franmomu requested a review from phansys June 9, 2024 17:35
@franmomu franmomu merged commit 043552d into doctrine-extensions:main Jun 24, 2024
22 checks passed
@mbabker mbabker deleted the deprecate-annotations branch June 24, 2024 13:23
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