Join GitHub today
[Serializer] Added scalar denormalization #35235
Just asking: does it really make sense for the Serializer and is it consistent to blindly cast the values?
We briefly discussed with @xabbuh this question and he expressed his point of view that this is rather a feature than a bug.
@ogizanagi if you insist I'm ready to rebase PR to 5.0 as a new feature implementation.
But scalar "normalization" in such case is simply "encoding". If you simply need decoding a scalar value, perhaps you should use
Actually I'm not certain where we're going here: if the aim is to get a bijective behavior between serialize & deserialize, then we also need to handle
$this->assertSame([2, 'foo'], $serializer->deserialize('[2, "foo"]', 'array', 'json')); $this->assertSame(null, $serializer->deserialize('null', 'null', 'json'));
right? (but that wouldn't even be enough to make it truly bijective)
In any case, I'd still argue this is a new usage of the Serializer, hence a feature for 5.1.
This PR was merged into the 5.1-dev branch. Discussion ---------- [Serializer] Added scalar denormalization | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #33784 | License | MIT Was added an ability to deserialize scalar data (single or array). Commits ------- dad04d0 Added scalar denormalization in Serializer + added scalar normalization tests