-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[PropertyInfo] Add accessor and mutator extractor interface and implementation on reflection #30704
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
[PropertyInfo] Add accessor and mutator extractor interface and implementation on reflection #30704
Conversation
03052ee
to
4f81ee7
Compare
This comment has been minimized.
This comment has been minimized.
8a6690b
to
95c8905
Compare
This comment has been minimized.
This comment has been minimized.
3877283
to
4e17c0a
Compare
Thanks @fabpot just updated the PR to reflect the change and extracting accessor / mutator with access flags. I also begin to add consistency to the extraction, but not sure this is wanted, here is a list of different behavior between
Support for each of this behavior can be done in constructor arguments or context, would prefer to avoid context and, in the future, use different |
This comment has been minimized.
This comment has been minimized.
I fully agree with this move. I also think we should make
I think so.
I'm not sure that the jQuery-style is still very used. jQuery itself is not used anymore in modern JS projects. It's why I not implemented it (and AFAIK nobody complained since the creation of this library). As a an alternative, we couldn't just deprecate support for this notation. WDYT?
It looks reasonable.
Yes, it could be nice as long as it's optional. I'm not sure that this feature is used a lot, but it could be useful for advanced use cases. |
I agree with @dunglas, that having hard dependencies between such components make sense (especially as they are low-level building blocks). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, i like these very limited information models as building blocks.
i guess a serializer would use these as one element along with other things like the target name (serializer) resp source name (deserialize)?
i commented some random thoughts i had while reading this. lets discuss tomorrow.
src/Symfony/Component/PropertyInfo/ReadAccessorExtractorInterface.php
Outdated
Show resolved
Hide resolved
Thanks @dbu for the review
With the global vision, serializer will never use this :) It intents to work as the following schema:
This will mask the complexity of accessing / setting value on the serializer component and also ensure that we can also read / write to / from an array or other dynamic object that does not have metadatas. |
thanks for the clarifications. and i think that makes sense. the only concern i have is with performance. large object graphs with many fields can mean A LOT of method calls. if there are several 10k of single fields to handle, method calls for each property start to add up. this is what prompted us to write https://github.com/liip/serializer/ . |
This is clearly something that i want to make it possible with new organisation / extension point. As we could do a specific PropertyAccess implementation that generate code given accessor / mutator (see the automapper pull request #30248 that have something like this), which will boost serializer by a large factor. |
b75cf43
to
f1c69ad
Compare
This comment has been minimized.
This comment has been minimized.
dca94fd
to
52b6fad
Compare
98e5554
to
37fdded
Compare
This is huge, thanks @Korbeil! |
37fdded
to
2fef84c
Compare
2fef84c
to
0a92dab
Compare
Thank you @joelwurtz and @Korbeil. |
…rface and implementation on reflection (joelwurtz, Korbeil) This PR was merged into the 5.1-dev branch. Discussion ---------- [PropertyInfo] Add accessor and mutator extractor interface and implementation on reflection | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #30248, partially: #22190, #18016, #5013, #9336, #5219, | License | MIT | Doc PR | TODO This PR brings accessor / mutator extraction on the PropertyInfo component, There is no link to existing code, as IMO it should be in another PR as this will add a dependency on property access to the property info component and not sure this is something wanted (although, it will reduce a lot of code base on the property access component as a lot of code seems to be duplicated) Code is extracted from #30248 also there is some new features (that can be removed if not wanted) * Allow extracting private accessor / mutator (will do a new PR that improve private extraction on reflection latter) * Allow extracting static accessor / mutators * Allow extracting constructor mutators Current implementation try to be as close as the PropertyAccess implementation and i did not reuse some methods already available in the class as there is some differences in implementation, but maybe it will be a good time to make this consistent (Looking forward to your input) ? Things that should be done in a new PR: * Linking property info to property access to remove a lot of duplicate code * Add a new system that allow adding Virtual Property based on this extractor Commits ------- 0a92dab Rebase, fix tests, review & update CHANGELOG fc25086 [PropertyInfo] Add accessor and mutator extractor interface and implementation on reflection
…orBuilder` (HeahDude) This PR was merged into the 5.1-dev branch. Discussion ---------- [PropertyAccess] Added missing new args in `PropertyAccessorBuilder` | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | ~ | License | MIT | Doc PR | ~ Following #30704. Commits ------- e1be8cd [PropertyAccess] Added missing new args in PropertyAccessorBuilder
… extractors (HeahDude) This PR was merged into the 5.1-dev branch. Discussion ---------- [FrameworkBundle][PropertyAccess] Use injection for info extractors | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | ~ | License | MIT | Doc PR | ~ Follows #30704. Commits ------- 693d4c0 [FrameworkBundle][PropertyAccess] Use injection for info extractors
This PR brings accessor / mutator extraction on the PropertyInfo component,
There is no link to existing code, as IMO it should be in another PR as this will add a dependency on property access to the property info component and not sure this is something wanted (although, it will reduce a lot of code base on the property access component as a lot of code seems to be duplicated)
Code is extracted from #30248 also there is some new features (that can be removed if not wanted)
Current implementation try to be as close as the PropertyAccess implementation and i did not reuse some methods already available in the class as there is some differences in implementation, but maybe it will be a good time to make this consistent (Looking forward to your input) ?
Things that should be done in a new PR: