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
[Serializer] Allow denormalization of constructor arguments to array of objects #27221
Conversation
Shouldn't this be implemented directly in the PropertyInfo component just as it was done for parsing types using the reflection API in #25605? |
@dunglas I think the answer to your question is here: #25524 (comment) Maybe it's not super clear from the diff but I barely introduced any new logic with this pull request. |
@cezarystepkowski it makes sense. As we try to avoid the proliferation of such methods in the abstract classes, can you mark them |
7b04753
to
1244faa
Compare
@dunglas I marked the methods as internal. Additionally, I rebased onto current master. |
@cezarystepkowski what is the status of this? This change is awesome and would definitely be a huge improvement. |
1244faa
to
0f9d01f
Compare
src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php
Outdated
Show resolved
Hide resolved
8272133
to
06ef399
Compare
@nicolas-grekas both suggested changes applied. |
Thanks. Would you mind rebasing please (and squashing meanwhile if you want)? We don't merge PRs that have merge commits. |
06ef399
to
cf58d82
Compare
@nicolas-grekas rebased and squashed :) |
A new entry is missing from |
@ogizanagi I updated the changelog, as version |
I am closing this PR as the same functionality has been already merged here: #29513 |
Currently it is not possible to denormalize array of objects passed to the class constructor as described in the issue #25524. When instantiating an object if constructor parameter is of array type its value is being set as it is without any further denormalization.
This pull request handles it by providing this further denormalization in the same way like it is currently done for non-constructor parameters. It means that now the constructor parameter type can be read from the php doc annotation and if it is an array of objects it will be denormalized correctly.