Skip to content

[Routing] Extend old Annotations from new Attributes #52544

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 1 commit into from
Nov 12, 2023

Conversation

curry684
Copy link
Contributor

If the base class is missing PHPStan fails to recognize the aliasing correctly.

Q A
Branch? 6.4
Bug fix? sort of
New feature? no
Deprecations? no
License MIT

Due to a shortcoming in PHPStan it does not pick up the previous aliasing correctly (ref. https://phpstan.org/r/2c7a9166-e8e1-42e5-8448-54c7d814e7d9).

This will cause projects to start failing their static analysis when they upgrade to 6.4. Explicitly extending the new attribute in the Attribute namespace has no runtime impact and shuts up PHPStan.

@nicolas-grekas
Copy link
Member

We should do the same for all classes patched in #52294
Can you please update them all?

@curry684
Copy link
Contributor Author

Yes, but not this weekend :)

@curry684
Copy link
Contributor Author

Turns out I had some time to spare, so done. I had to remove some final keywords but imho they were pretty useless anyway in these attributes.

@curry684 curry684 changed the title [Routing] Extend Annotation route from new Attribute route [Serializer][Routing] Extend old Annotations from new Attributes Nov 10, 2023
@carsonbot carsonbot changed the title [Serializer][Routing] Extend old Annotations from new Attributes [Routing] Extend old Annotations from new Attributes Nov 11, 2023
@@ -20,7 +20,7 @@
* @author Kévin Dunglas <dunglas@gmail.com>
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_PROPERTY)]
final class Ignore
Copy link
Member

Choose a reason for hiding this comment

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

Please add the @final annotation so that we don't support BC for child classes (as they might not work when reading attributes anyway)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough, should be noted that many other attributes (ie. in DependencyInjection) are also not marked final. Out of scope for this PR to look into that.

Copy link
Member

Choose a reason for hiding this comment

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

For some of them, it is intended as we explicit added support for extending them.

@fabpot
Copy link
Member

fabpot commented Nov 12, 2023

Thank you @curry684.

@fabpot fabpot merged commit 6c91073 into symfony:6.4 Nov 12, 2023
@curry684 curry684 deleted the patch-3 branch November 12, 2023 22:48
curry684 added a commit to omines/antispam-bundle that referenced this pull request Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants