-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
mixed fails to serialize objects #23
Comments
The problem here is that we will never be able to deserialize an object to mixed, as there's no indication of what the type is. Serialization is possible, but you're really better off specifying a real type in PHP. |
Deserialization isn't an issue (the type is identified correctly by the deserializer through Use-case: basically a wrapper containing metadata around a (de)serializable domain object. |
On a lark, try the |
OK, tested it, and it won't work. The problem is the refactored approach sends the value to serialize back through the serializer, which means the same object goes through Serializer::serialize() twice. Which... trips the circular dependency detection. :-) I don't know how to resolve that at this point, so unless someone has an idea it likely won't make it into the 1.0 release this month. |
If it is mixed, and an object, can't it get the type via |
Yes, but there's a lot of prep-work involved in preparing an object for exporting. So what it does right now is use Which is what triggers the circular dependency detection. |
Ah, I see. FWIW, my workaround of simply serializing the mixed object to an array and then serializing the wrapping object into whatever seems to work fine. It takes a bit of extra work, but if you're wrapping an object with an object, you're already in a position to do that. So, maybe this just needs to be documented so that it isn't a surprise? |
Detailed description
When an object contains a
mixed
property containing an object, the property fails to serialize inMixedExporter
due to not being anarray
,int
,float
,bool
, orstring
.Context
It would be nice to serialize generic objects.
Workaround
The workaround is to call
$serde->serialize(...)
on the mixed property and then serialize the parent object.The text was updated successfully, but these errors were encountered: