You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
When the AbstractNormalizer detects a constructor variadic argument, it ignores the type hint of the argument, so the deserialization process throws a TypeError.
{"orderLines":[{"concept":"A"},{"concept":"B"}]}
PHP Fatal error: Uncaught TypeError: Argument 1 passed to Order::__construct() must be an instance of OrderLine, array given in /tmp/lala/bug.php:26
Stack trace:
#0 [internal function]: Order->__construct(Array, Array)
#1 /tmp/lala/vendor/symfony/symfony/src/Symfony/Component/Serializer/Normalizer/AbstractNormalizer.php(387): ReflectionClass->newInstanceArgs(Array)
#2 /tmp/lala/vendor/symfony/symfony/src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php(185): Symfony\Component\Serializer\Normalizer\AbstractNormalizer->instantiateObject(Array, 'Order', Array, Object(ReflectionClass), false, 'json')
#3 /tmp/lala/vendor/symfony/symfony/src/Symfony/Component/Serializer/Serializer.php(182): Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer->denormalize(Array, 'Order', 'json', Array)
#4 /tmp/lala/vendor/symfony/symfony/src/Symfony/Component/Serializer/Serializer.php(133): Symfony\Component\Serializer\Serializer->denormalize(Array, 'Order', 'json', Array)
#5 /tmp/lala/bug.php(42): Symfony\Component\ in /tmp/lala/bug.php on line 26
The text was updated successfully, but these errors were encountered:
ajgarlag
changed the title
Support denormalization of object with variadic constructor typed argument
[Serializer] Support denormalization of object with variadic constructor typed argument
May 9, 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
Symfony version(s) affected: 3.4 up to 4.2
Description
When the AbstractNormalizer detects a constructor variadic argument, it ignores the type hint of the argument, so the deserialization process throws a TypeError.
How to reproduce
Expected output:
Current output:
The text was updated successfully, but these errors were encountered: