Skip to content

[Serializer] add can to the accessor prefixes recognized by the AttributeLoader #61023

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

Open
wants to merge 3 commits into
base: 7.4
Choose a base branch
from

Conversation

themasch
Copy link
Contributor

@themasch themasch commented Jul 2, 2025

Q A
Branch? 7.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #61021
License MIT

The ObjectNormalizer already recognizes canX as an accessor and "generates" a property for that, the AttributeLoader does not, so #[Ignore] attributes on canX are ignored, the return value is encoded in the normalized data.

We just add the can prefix ot the list of accepted accessor prefixes, so the AttributeLoader now also recognized these.

I adapted a test that seemd to me to fit the best. If you'd prefer a dedicated test for that, I can do that, too.

…he AttributeLoader

The ObjectNormalizer already recognizes `canX` as an accessor and "generates" a property for that, the AttributeLoader does not, so #[Ignore] attributes on `canX` are ignored, the return value is encoded in the normalized data.

We just add the `can` prefix ot the list of accepted accessor prefixes, so the AttributeLoader now also recognized these.
@carsonbot

This comment has been minimized.

@carsonbot carsonbot added this to the 7.4 milestone Jul 2, 2025
@carsonbot carsonbot changed the title bug #61021: add can to the accessor prefixes recognized by the AttributeLoader [Serializer] bug #61021: add can to the accessor prefixes recognized by the AttributeLoader Jul 2, 2025
@OskarStark OskarStark changed the title [Serializer] bug #61021: add can to the accessor prefixes recognized by the AttributeLoader [Serializer] add can to the accessor prefixes recognized by the AttributeLoader Jul 2, 2025
Comment on lines 32 to 36
#[Ignore]
public function getSomethingElse(): int
{
return 42;
}
Copy link
Member

Choose a reason for hiding this comment

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

This additional test case seems not related to your PR topic. Is there a use for it that I've missed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to check the behaviour for getX and make sure it keeps working after my change.
If you want me to remove it, I can do that.

Copy link
Member

Choose a reason for hiding this comment

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

As it seems already covered by getIgnored2, I think you can remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ignored2 is itself a property, I wanted to make sure it also works if its just the accessor, without any obvious property backing it. But I'll remove it.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

Can you please add a line to the changelog file of the component?

@themasch
Copy link
Contributor Author

themasch commented Jul 7, 2025

@nicolas-grekas like this?

Comment on lines +6 to +8
* Add support for `can*()` methods to `AttributeLoader`

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Add support for `can*()` methods to `AttributeLoader`
* Add support for `can*()` methods to `AttributeLoader`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤦 yes, sorry. fixed that.

@themasch themasch force-pushed the serializer-ignore-caner branch from 2003146 to 2d7a3fb Compare July 7, 2025 07:29
@themasch
Copy link
Contributor Author

themasch commented Jul 7, 2025

Would it make sense to backport this to 7.3, 7.2 and 6.4, or would that be to big of a BC break?

@stof
Copy link
Member

stof commented Jul 7, 2025

New features are never backported in patch versions.

@themasch
Copy link
Contributor Author

themasch commented Jul 7, 2025

Okay, so this counts as a new feature, not a bug fix? Good to know, so we'll need to wait for 7.4 to remove our work around! Thanks!

@OskarStark OskarStark changed the title [Serializer] add can to the accessor prefixes recognized by the AttributeLoader [Serializer] add can to the accessor prefixes recognized by the AttributeLoader Jul 7, 2025
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.

[Serializer] ObjectNormalizer recognizes canX as getter, but Attribute loader does not
7 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy