[Serializer] Fix denormalization of object with variadic constructor typed argument #31438
Merged
nicolas-grekas merged 1 commit intosymfony:3.4from May 11, 2019
Conversation
1171ce3 to
7108f84
Compare
36056a4 to
995d189
Compare
Contributor
Author
|
PR ready to merge |
dunglas
requested changes
May 10, 2019
src/Symfony/Component/Serializer/Tests/Normalizer/AbstractNormalizerTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php
Outdated
Show resolved
Hide resolved
| ); | ||
|
|
||
| $params = array_merge($params, $variadicParameters); | ||
| unset($data[$key]); |
Contributor
Author
There was a problem hiding this comment.
Without this change, when using the PropertyNormalizer, the deserialized object is successfully instantiated, but the property is overwritten again with the original $data[$key] array value ignoring the type hint.
dunglas
approved these changes
May 10, 2019
nicolas-grekas
approved these changes
May 11, 2019
nicolas-grekas
approved these changes
May 11, 2019
a736781 to
c8c3c56
Compare
Member
|
Thank you @ajgarlag. |
nicolas-grekas
added a commit
that referenced
this pull request
May 11, 2019
…onstructor typed argument (ajgarlag) This PR was squashed before being merged into the 3.4 branch (closes #31438). Discussion ---------- [Serializer] Fix denormalization of object with variadic constructor typed argument | Q | A | ------------- | --- | Branch? | 3.4 up to 4.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #31436 | License | MIT This PR adds a test to demonstrate the bug, and a fix to squash it. Commits ------- c8c3c56 [Serializer] Fix denormalization of object with variadic constructor typed argument
Contributor
Author
|
@nicolas-grekas I'd like to have this issue fixed in 4.2 branch too. Can you tell me when will be merged into that branch? Thanks. |
Member
|
There is nothing to do on your side, we will merge 3.4 into 4.2 with the fix. |
|
@nicolas-grekas, the fix breaks current workaround $extractor = new PropertyInfoExtractor([], [new PhpDocExtractor(), new ReflectionExtractor()]);
$normalizer = new PropertyNormalizer(null, null, $extractor);<?php
namespace Symfony\Component\Serializer\Tests\Fixtures;
final class VariadicConstructorAnnotationTypedArgsDummy
{
/** @var Dummy[] */
private $foo;
public function __construct(...$foo)
{
$this->foo = $foo;
}
public function getFoo()
{
return $this->foo;
}
} |
This was referenced May 22, 2019
Merged
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a test to demonstrate the bug, and a fix to squash it.