Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70581 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 97651 invoked from network); 11 Dec 2013 01:38:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2013 01:38:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qa0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:55999] helo=mail-qa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/01-27591-912C7A25 for ; Tue, 10 Dec 2013 20:38:33 -0500 Received: by mail-qa0-f42.google.com with SMTP id k4so4317984qaq.15 for ; Tue, 10 Dec 2013 17:38:30 -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=VlcPoj7fmLGY68rVWcdxkauSFftY6eia+Z2mSkoFgV4=; b=OCDCrHHgNhTxPoIciSMcdbcAwgF0Dnt2KcZ/6NcQD+uiJqZKOiqV218GnjcB/exQou oIQoVHbV8P3rPPlW2kqa6BmKTSoQA2kyj5mS0nx3Ts/Mdt5pTt1Wi7pwoDJAOURwfZQH UOAolbF/LsRep5OvR+7iU95YaLJtm0y0ktOfktlmECco0zj0Ga9sT7fP7E1BqeABH180 lM4ram3dTSUvdigAek7NIcoYy29tuNyo9X5GdvPHDgiVXCMFXcMMXjA79nZ2E18LLhzB ZdQwwb1ZvDgz/s/dLt0Tfe9Vm+lz55vXnuv/y/0bvs9CgDgSUYx2uaGCXaVUtAWdKnEX Lh5w== X-Received: by 10.49.109.200 with SMTP id hu8mr17148421qeb.72.1386725910189; Tue, 10 Dec 2013 17:38:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.23.176 with HTTP; Tue, 10 Dec 2013 17:38:10 -0800 (PST) In-Reply-To: References: Date: Wed, 11 Dec 2013 02:38:10 +0100 Message-ID: To: chobie Cc: PHP internals Content-Type: multipart/alternative; boundary=047d7bea36d2471d2004ed38497a Subject: Re: [PHP-DEV] Proposal: ArraySerializable interface From: ocramius@gmail.com (Marco Pivetta) --047d7bea36d2471d2004ed38497a Content-Type: text/plain; charset=UTF-8 On 11 December 2013 02:36, Marco Pivetta wrote:class ObjectToArrayConverter > { > /** > * @param mixed $value > * > * @raturn array > */ > public static function toArray($value) > { > if (! (is_object($value) || is_array($value))) { > return $value; > } > > if (is_object($value) && method_exists($value, '__toArray')) { > return $value->__toArray(); > } > > return array_map(__METHOD__, (array) $value); > } > } > > Note: I didn't consider the case of cyclic references. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --047d7bea36d2471d2004ed38497a--