Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Serializer] Fix denormalizing nested arrays as object values #30258

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

Closed
wants to merge 1 commit into from

Conversation

mcfedr
Copy link
Contributor

@mcfedr mcfedr commented Feb 15, 2019

Q A
Branch? 4.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets N/A
License MIT
Doc PR N/A

Currently the ObjectNormalizer loses type information for nested arrays in its properties, resulting in failed denormalization

Basically if i have this property

/** @var Child[][] */
public $children;

The ObjectNormalizer just sees this as a 'array' type and injects the raw array, rather than passing it back to the Serializer with class Child[][]

@@ -52,6 +52,13 @@ public function denormalize($data, $class, $format = null, array $context = [])
$class = substr($class, 0, -2);

$builtinType = isset($context['key_type']) ? $context['key_type']->getBuiltinType() : null;

// Fix a collection that contains the only one element
// This is special to xml format only
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fix was in ObjectNormalizer, I think it makes more sense here, and now with the recursive types its harder to fit into ObjectNormalizer.

@mcfedr mcfedr changed the title Fix denormalizing nested arrays as object values [Serializer] Fix denormalizing nested arrays as object values Feb 15, 2019
@mcfedr mcfedr force-pushed the serializer-nested-array branch 2 times, most recently from 784b9f0 to 9c93527 Compare February 15, 2019 15:57
@nicolas-grekas nicolas-grekas added this to the 4.2 milestone Feb 16, 2019
@nicolas-grekas nicolas-grekas changed the base branch from master to 4.2 February 16, 2019 17:28
@mcfedr mcfedr force-pushed the serializer-nested-array branch 6 times, most recently from fa2065a to f42b39e Compare February 20, 2019 08:31
@mcfedr mcfedr force-pushed the serializer-nested-array branch from f42b39e to b87b268 Compare May 24, 2019 09:48
@mcfedr mcfedr changed the base branch from 4.2 to 4.3 May 24, 2019 09:53
@mcfedr
Copy link
Contributor Author

mcfedr commented May 24, 2019

@nicolas-grekas Resolved all the comments, also rebased on 4.3

@fabpot fabpot modified the milestones: 4.2, 4.3 Jul 28, 2019
@mcfedr mcfedr force-pushed the serializer-nested-array branch from b87b268 to 820c052 Compare September 16, 2019 08:07
@mcfedr mcfedr force-pushed the serializer-nested-array branch from 820c052 to 952527d Compare September 16, 2019 08:08
@nicolas-grekas nicolas-grekas removed this from the 4.3 milestone Feb 1, 2020
@nicolas-grekas nicolas-grekas added this to the 4.4 milestone Feb 1, 2020
@nicolas-grekas
Copy link
Member

@mcfedr I think we lost track of this PR, and the code changed now, so that there is a conflict to resolve.

Could you please rebase this PR on 4.4?

@nicolas-grekas nicolas-grekas changed the base branch from 4.3 to 4.4 January 23, 2021 18:30
@nicolas-grekas
Copy link
Member

Closing because this stalled, but more importantly because this might have been fixed in #32832 already.

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.

5 participants