-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Fix denormalization of object with variadic constructor typed argument #31438
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 denormalization of object with variadic constructor typed argument #31438
Conversation
1171ce3
to
7108f84
Compare
36056a4
to
995d189
Compare
PR ready to merge |
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]); |
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.
Why this change?
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.
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.
a736781
to
c8c3c56
Compare
Thank you @ajgarlag. |
…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
@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. |
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 PR adds a test to demonstrate the bug, and a fix to squash it.