Hi Nikita,

I'd like to propose a new custom object serialization mechanism intended to
> replace the broken Serializable interface:
>
> https://wiki.php.net/rfc/custom_object_serialization
>
> This was already previously discussed in
> https://externals.io/message/98834, this just brings it into RFC form.
> The latest motivation for this is https://bugs.php.net/bug.php?id=77302,
> a compatibility issue in 7.3 affecting Symfony, caused by Serializable. We
> can't fix Serializable, but we can at least make sure that a working
> alternative exists.
>

Is there anything we can to do to help the RFC move forward? I'm spending a
great deal of time removing Serializable from the Symfony code base. It's
not pretty nor fun... but we have no choice since as ppl move to PHP 7.3,
they can now spot when the current mechanism is breaking their serialized
payloads (typically from user objects put in the session storage).

About interface vs magic methods, technicaly, we can work with an interface
provided by PHP core, so that if that's a blocker for voters to approve the
RFC, let's do it - the current situation is really aweful :). FYI, I found
myself implementing some getState()/setState() methods of my own, decoupled
from the underlying mechanisms used by PHP. That allows me to still use
Serializable for BC reasons when needed, or  move to __sleep when possible,
then move to the new 7.4 style when ready, without requiring any changes
from the consumer POV. That's a good illustration of what I meant in my
previous email: domain-specific interfaces in everyone's code is a better
design as it allows better decoupling. It's also a better design to express
that "instances of this interface of mine MUST be serializable". IMHO.

Nicolas

Reply via email to