Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103835 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82652 invoked from network); 24 Jan 2019 18:28:05 -0000 Received: from unknown (HELO shout02.mail.de) (62.201.172.25) by pb1.pair.com with SMTP; 24 Jan 2019 18:28:05 -0000 Received: from postfix01.mail.de (postfix03.bt.mail.de [10.0.121.127]) by shout02.mail.de (Postfix) with ESMTP id 46CD6C00CB; Thu, 24 Jan 2019 16:06:13 +0100 (CET) Received: from smtp02.mail.de (smtp02.bt.mail.de [10.0.121.212]) by postfix01.mail.de (Postfix) with ESMTP id 2EC7980070; Thu, 24 Jan 2019 16:06:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mailde201610; t=1548342373; bh=ywtn9ouXqNkcwR0hxwnX9z8s9gTbI+tSli5iyw1lQKQ=; h=From:To:Cc:Subject:Date:From; b=iz/b2McBzDhpRAX63PD41l8xEp9elWiRsTwzZECeYjYCkKsQA4YcOpgJkA9czvyia +M0fvQ6BbQtKLlHOvvcQeMgdo0bQvUAs/wzh5rLFQCJZAKKsExvYv6hDwNqUCmpIbU 4J6WVoe8KouoFcx/BkgeIVzX6NEUsssPYq4sGEU8= Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp02.mail.de (Postfix) with ESMTPSA id F28C6100432; Thu, 24 Jan 2019 16:06:12 +0100 (CET) To: nikita.ppv@gmail.com Cc: internals@lists.php.net X-Priority: 3 Date: Thu, 24 Jan 2019 16:06:12 +0100 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline MIME-Version: 1.0 Message-ID: <20190124150612.F28C6100432@smtp02.mail.de> X-purgate: clean X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 2856 X-purgate-ID: 154282::1548342373-00001E9E-A390D273/0/0 Subject: Re: [PHP-DEV] [RFC] New custom object serialization mechanism From: naitsirch@e.mail.de Sorry, forgot to CC the following mail to internals:=0A=0AAm 24-Jan-2019= 14:28:43 +0100 schrieb nikita.ppv@gmail.com:=0A> =0A> On Thu, Jan 24, 2= 019 at 2:15 PM wrote:=0A> > On Thu, Jan 24, 2019 a= t 13:27 Nikita Popov =0A> > wrote:=0A> > =0A> > >= Hi internals,=0A> > > =0A> > > I'd like to propose a new custom object= serialization mechanism intended to=0A> > > replace the broken Serializ= able interface:=0A> > > =0A> > > https://wiki.php.net/rfc/custom_object_= serialization=0A> > > =0A> > > This was already previously discussed in= https://externals.io/message/98834,=0A> > > this just brings it into RF= C form. The latest motivation for this is=0A> > > https://bugs.php.net/b= ug.php?id=3D77302, a compatibility issue in 7.3=0A> > > affecting Symfon= y, caused by Serializable. We can't fix Serializable, but=0A> > > we can= at least make sure that a working alternative exists.=0A> > > =0A> > >= Regards,=0A> > > Nikita=0A> > =0A> > Hi.=0A> > =0A> > What happens if b= oth `__serialize()` and `__wakeup()` are implemented?=0A> =0A> You mean= if there are just those two methods, but not __unserialize() for exampl= e?=0A> In that case the array returned by __serialize() will be unserial= ized as object=0A> properties and __wakeup() will be called for finaliza= tion. In principle it's okay to=0A> use this combination, though it woul= d be somewhat unusual.=0A=0A=0ASorry, what I wanted to ask was, what hap= pens if `__serialize()` and `__SLEEP()` are implemented? xD=0A=0AHere's= an example:=0A=0Aclass A {=0A private $foo =3D 'foo';=0A private= $bar =3D 'bar';=0A=0A function __serialize() {=0A return ['fo= o' =3D> $this->foo];=0A }=0A=0A function __sleep() {=0A ret= urn ['bar'];=0A }=0A}=0A=0Aecho serialize(new A());=0A=0AWhat will be= the output of the above snippet?=0A=0A> =0A> > And another idea for the= naming: Maybe one could use `__normalize()` and `__denormalize()`. Beca= use the methods do not serialize themself, like the normalizer in the Sy= mfony serializer component. =0A> =0A> I'd like that "serialization" appe= ars in some form in the name, to make clear in what context this is used= . Normalization is a fairly general term and could refer to any number o= f things.=0A> =0A> Nikita=0A=0AYes, you are right. It is just, that my p= ersonal taste for function names is that they should describe what they= do. New users may be irritated about the function name.=0AMaybe a more= explicit name would be `__toSerializable`.=0A=0ABut I have no idea for= the counterpart ^^=0A=0ABest regards,=0A=0AChristian=0A----------------= ------------------------------------------------------------------------= ---------=0AFreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSIT=C3= =84T UND KOMFORT