Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70613 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68111 invoked from network); 12 Dec 2013 23:20:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Dec 2013 23:20:21 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.46 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.128.46 mail-qe0-f46.google.com Received: from [209.85.128.46] ([209.85.128.46:51079] helo=mail-qe0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/55-32587-2B44AA25 for ; Thu, 12 Dec 2013 18:20:18 -0500 Received: by mail-qe0-f46.google.com with SMTP id a11so988912qen.33 for ; Thu, 12 Dec 2013 15:20:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=/z8LPoGz8ChQ/eTbLD8m3PWIuFdY19MVbAK6Sx9YhQw=; b=mqHoI5gK7mNvpXTIxUIE7prvq++qtA/GxRYeQe0LKgRjUbTJ1DMpYK1px9y5uZFDom yTjalpxri3rW568434bfbwbwuorqP74byYaLa4XInmnA7Gp8tmIf/z8wJqALfeRuvU6q 4FZ9gFXc6CPih6AZBHhnVSZMcUbY3/ykMpdRvULrcigtZ6MCSxOdK8T6fyP84m4+9aZb SrMi4WK26U9hhbFWfHD6l12zQTbZm/b0yZ6aiGOy3CrzOtAC2YJPcUVgbN5gYUNEJ9nq y//kmel6Fa1Ac/y4pz/5kiH69GC9XzuqH28MDjSfyRK+FQXWMBGlnspNhZmSfwrhC1s8 DlVw== X-Received: by 10.49.17.196 with SMTP id q4mr18212600qed.31.1386890415060; Thu, 12 Dec 2013 15:20:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.85.149 with HTTP; Thu, 12 Dec 2013 15:19:55 -0800 (PST) In-Reply-To: References: Date: Fri, 13 Dec 2013 00:19:55 +0100 Message-ID: To: chobie Cc: PHP internals Content-Type: multipart/alternative; boundary=047d7bdc94ca883f7c04ed5e96c2 Subject: Re: [PHP-DEV] Proposal: ArraySerializable interface From: ocramius@gmail.com (Marco Pivetta) --047d7bdc94ca883f7c04ed5e96c2 Content-Type: text/plain; charset=UTF-8 On 11 December 2013 16:29, chobie wrote: > 2013/12/11 Marco Pivetta : > > > > I'm actually wondering about the opposite case. > > What would I have to do to have the previous behavior working on an > `ArraySerializable` instance (basically ignore `__toArray()` for one > particular cast)? > > I don't want to go the reflection way :-) > > I'm curious about your story. What king of work do you do? > There are quite a lot of cases where array cast behavior is currently something we rely on (to avoid reflection). Here's two that come into my mind: - Using `__sleep()` and returning array keys for parent classes' properties: public function __sleep() { return array_keys((array) $this); // handles the "\0*\0" or "\0ClassName\0" properties } - Relying on `(array)` casting returning all property names all the time - Some stuff I've been working about converting objects to arrays to objects (GeneratedHydrator) Those are some of the bc breaks that I have on top of my mind. I'd rather prefer having userland implementations as I mentioned before (since it's possible). Casting to `(array)` actually solves more complex problems, while solving the problem of extracting data is fairly simple Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --047d7bdc94ca883f7c04ed5e96c2--