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
This PR was merged into the 5.4 branch.
Discussion
----------
[Serializer] Fix denormalize constructor arguments
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fixsymfony#52499, Fixsymfony#52422
| License | MIT
Since this PR: symfony#51907, objects with partial constructor parameters were wrongly instantiated.
This PR fixes that issue by delegating the properties values assignment, by unsetting normalized data only when the constructor has been called properly.
This might correct symfony#50759 as well.
Commits
-------
8f7c7ae [Serializer] Fix denormalize constructor arguments
self::assertSame(sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires the following parameters to be present : "$bar", "$baz".', ConstructorArgumentsObject::class), $e->getMessage());
self::assertSame(sprintf('Cannot create an instance of "%s" from serialized data because its constructor requires the following parameters to be present : "$foo", "$baz".', ConstructorArgumentsObject::class), $e->getMessage());
Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/SerializerTest.php
+20-1
Original file line number
Diff line number
Diff line change
@@ -868,7 +868,8 @@ public function testCollectDenormalizationErrors(?ClassMetadataFactory $classMet
868
868
],
869
869
"php74FullWithConstructor": {},
870
870
"php74FullWithTypedConstructor": {
871
-
"something": "not a float"
871
+
"something": "not a float",
872
+
"somethingElse": "not a bool"
872
873
},
873
874
"dummyMessage": {
874
875
},
@@ -1032,6 +1033,24 @@ public function testCollectDenormalizationErrors(?ClassMetadataFactory $classMet
1032
1033
'useMessageForUser' => false,
1033
1034
'message' => 'The type of the "something" attribute for class "Symfony\Component\Serializer\Tests\Fixtures\Php74FullWithTypedConstructor" must be one of "float" ("string" given).',
'message' => 'The type of the "something" attribute for class "Symfony\Component\Serializer\Tests\Fixtures\Php74FullWithTypedConstructor" must be one of "float" ("string" given).',
'message' => 'The type of the "somethingElse" attribute for class "Symfony\Component\Serializer\Tests\Fixtures\Php74FullWithTypedConstructor" must be one of "bool" ("string" given).',
0 commit comments