Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:103827 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 59345 invoked from network); 24 Jan 2019 17:29:43 -0000 Received: from unknown (HELO out5-smtp.messagingengine.com) (66.111.4.29) by pb1.pair.com with SMTP; 24 Jan 2019 17:29:43 -0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 25D4A23075 for ; Thu, 24 Jan 2019 09:07:52 -0500 (EST) Received: from imap26 ([10.202.2.76]) by compute7.internal (MEProxy); Thu, 24 Jan 2019 09:07:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:references:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=KJTgCuboAR6bXAoM/ bC6ExHlc7WEz4ZSqsvH3PDQGrk=; b=DauCqt++2sQ1fgVC9pkDKcIPr6PhfKiWp dcCp8nQlVoclSRLk9NsElf5WYOeApoKNxg3kI+rXT6IqTfHy/t4w1m2WO0fFSHv7 slX6DuCauDyysC6Itox227bqd4w1K96ZOEoZfX8XPZf3+YMlhJB/tIJK4N56e0L8 kw/A6JMBDcmFGaJxR6anzIy1egAKLe/JXnAVfQAGqLnE/LIvNgAyPI0iTuiyZrhy 6i/gj/fum2DIavzUveAk5zFJt2ZQSfqdrt2bngssFR2nzcyqOm7z/IfEV4yyvUlY 64I3X5AFsY8ORc4vXwtdnmLIAKeVsze8ZfZ3yTxypEuTv5sz37zgw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledriedvgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucenucfjughrpefofgfkjghffffhvffutgesthdtredtreertdenucfhrhhomhepfd fnrghrrhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghh rdgtohhmqeenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlh guthgvtghhrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id A308CB4202; Thu, 24 Jan 2019 09:07:51 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.1.5-766-ge2be361-fmstable-20190123v1 X-Me-Personality: 10727885 Message-ID: <96949d28-1b59-4d8b-9db7-6c5047d180f7@www.fastmail.com> In-Reply-To: References: <20190124131514.CD9051000DB@smtp02.mail.de> Date: Thu, 24 Jan 2019 09:07:45 -0500 To: internals@lists.php.net Content-Type: text/plain Subject: Re: [PHP-DEV] [RFC] New custom object serialization mechanism From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jan 24, 2019, at 8:02 AM, Nicolas Grekas wrote: > Thank you Nikita, > > the RFC looks solid to me. Using magic methods makes perfect sense to allow > a smooth migration path. > > We could enforce that if one of __serialize() or __unserialize() is > > defined, both have to be defined, to avoid running into such cases. > > > That would make sense a lot of sense to me. > > > > Maybe one could use `__normalize()` and `__denormalize()` [...] > > > I'd like that "serialization" appears in some form in the name > > > > An idea: __pre_serialize / __post_unserialize > But __serialize/__unserialize are good to me. > > Nicolas Given that these methods would not be producing/consuming strings but a de-classed representation of the object, I agree that it's closer to "normalize" as Symfony uses the term. We don't have to use that name specifically but something other than serialize/deserialize seems logical. Also, that in turn suggests that the same mechanism could be leveraged for formats other than the C (or 0? It's referred to both ways in the RFC) format we all know and grudgingly accept. Eg, it feels an awful lot like JsonSerializable (which is for serialize only, but also returns an array), and I can definitely see uses for a standard intermediary format that could be encoded to C-serialized, JSON, or XML, or whatever else. Is there some way that we could allow other systems to hook into it cleanly, such that it becomes a common intermediary format for a variety of stringified formats? --Larry Garfield