Re: [RFC] New custom object serialization mechanism

From: Date: Thu, 24 Jan 2019 15:00:07 +0000
Subject: Re: [RFC] New custom object serialization mechanism
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-103834@lists.php.net to get a copy of this message
On Thu, 24 Jan 2019 at 14:53, Thomas Bley <mails@thomasbley.de> wrote: > To me it's not clear why we need all these methods, for example: > > $a = new A(); > $aSerialized = serialize($a->toArray()); > $aRestored = A::createFromArray(unserialize($aSerialized)); > > Apart from security problems, problems with versioning and unreadable data > in databases, > I don't see many benefits from using serialize()/unserialize(). > That looks like basically the same methods as proposed, but with different names: class A has implemented toArray(), and it either recursively calling toArray() on other objects, or is returning those instances for default handling by serialize(). If the proposed functions were marked as a generic serialization interface, as Larry suggests, they would just be standardising this exact pattern. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#103834) next »