Closed netbrothers-tr closed 11 months ago
Hi!
JMS Serialiser currently supports not static uninitialised properties, but static uninitialised properties are not supported yet. I guess it would be a simple change in the library, so feel free to create Pull Request with the changes. :) See: https://github.com/schmittjoh/serializer/blob/5a5a03a71a28a480189c5a0ca95893c19f1d120c/src/Accessor/DefaultAccessorStrategy.php#L99
Best, scyzoryck.
Maybe it'd be best if a serialization handler was provided for the class. The Symfony serializer actually has a normalizer dedicated to handling objects from the symfony/mime
component (https://github.com/symfony/symfony/pull/37847) instead of falling back to some default handler, and in the case of the Address
class specifically, I imagine that trying to handle its internal details (the encoder and validator) during serialization is not intended.
JMS Serialiser currently supports not static uninitialised properties, but static uninitialised properties are not supported yet. I guess it would be a simple change in the library, so feel free to create Pull Request with the changes. :)
@scyzoryck, thanks for pointing out the different handling of static vs. regular properties. However, this isn't (and probably shouldn't be?) done by simply adjusting the regular expression. I'm not sure why, but static properties are handled differently as you can see here and here and the exception occurs even before the regular expression is evaluated.
Maybe it'd be best if a serialization handler was provided for the class.
@mbabker, I think that's generally the right approach. In my case, however, I will opt for a different (self written) class and convert that to Symfony\Component\Mime\Address
when needed. Thank you nevertheless.
Simple serialization of objects of the given type fails. I am curious, what I might have overlooked. It might also be a bug.
Steps required to reproduce the problem
Set up a project with Serializer and Symfony Mime.
Create a simple serialization case.
This could be a problem with Symfony Mime, because if you call their
toString()
method before the serialization, the problematic encoder in theAddress
class gets initialized and doesn't cause the uninitialized exception anymore.Standard PHP serialization works without a problem.
Expected Result
I would expect the serialization to work out of the box.
Actual Result
The following exception is thrown.