Skip to content
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] Fix denormalizing nested arrays as object values #30258

Open
wants to merge 1 commit into
base: 4.3
from

Conversation

Projects
None yet
3 participants
@mcfedr
Copy link
Contributor

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

This comment has been minimized.

Copy link
@mcfedr

mcfedr Feb 15, 2019

Author Contributor

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 mcfedr:serializer-nested-array branch 2 times, most recently from 784b9f0 to 9c93527 Feb 15, 2019

@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 Feb 16, 2019

@mcfedr mcfedr force-pushed the mcfedr:serializer-nested-array branch 6 times, most recently from fa2065a to f42b39e Feb 19, 2019

@mcfedr mcfedr force-pushed the mcfedr:serializer-nested-array branch from f42b39e to b87b268 May 24, 2019

@mcfedr mcfedr requested review from dunglas, lyrixx, sroze and xabbuh as code owners May 24, 2019

@mcfedr mcfedr changed the base branch from 4.2 to 4.3 May 24, 2019

@mcfedr

This comment has been minimized.

Copy link
Contributor Author

commented May 24, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.