On Tue, 5 Feb 2019 at 16:06, Dennis Birkholz <p...@dennis.birkholz.biz>
wrote:

> Maybe for PHP 8 we
> will decide to require all classes to be serializable except classes
> that implement the Unserializable interface or something... Or the magic
> __isSerializable() method that can decide this at runtime for the actual
> state of an object without failing hard when trying it.
>


I agree, it can be very confusing if you have something like a SimpleXML
object buried somewhere, and your serialize() call blows up. (See the
example I've raised a couple of times where Exceptions may or may not be
serializable, because they slurp up objects from everywhere in their
backtrace.)

I was going to suggest this would fit with the discussion Nikita raised
about adding a new serialization mechanism, but thinking about it more, I'm
not sure how the API for this would work. If you don't recursively check
that the properties of an object are also serializable, the call is
useless; but if you do, it's really no different from try {
serialize($foo); } catch {}

Regards,
-- 
Rowan Collins
[IMSoP]

Reply via email to