Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:70585 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 20980 invoked from network); 11 Dec 2013 08:18:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Dec 2013 08:18:09 -0000 Authentication-Results: pb1.pair.com header.from=leight@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.175 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 74.125.82.175 mail-we0-f175.google.com Received: from [74.125.82.175] ([74.125.82.175:61305] helo=mail-we0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A7/52-04685-0CF18A25 for ; Wed, 11 Dec 2013 03:18:09 -0500 Received: by mail-we0-f175.google.com with SMTP id t60so6025185wes.6 for ; Wed, 11 Dec 2013 00:18:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=tCSrmEVt3kdqHzVTEIX+eT1ZO/djf2xd9/eP7+dMhsY=; b=ZJvCXMxdDdzvWO9oD+pyJ3RdBsYdFAP/zCJ7V7T6TdIlm3wO3/AMjlO18K6Ha0hKy/ VxfSbYjNIDqXoLTXLB6W0EsGJAYOvaWf9eHbeoR/3DGLRf+nPGKCv+ZdCyafzuCoG+gT 14cxqS1py5yX6gbAVTLBZbjQYj2eIhAafnkw0lRxH+zYHrTdjVlfSzbiBXu8SB6jemOJ 0nQTLdjMD2NE8v8aIHI4xkqHYrm0HHKjlO7XOZur8/dNJITBDhdwCN46HfIg+mHZUVYW 1T02Y3LPoATEYtQJ9IMcR49PW/mBE7R8qV4TzrZmA6FA5Qwfj+TsuM+cWwKWo4UfNpif 7CDw== MIME-Version: 1.0 X-Received: by 10.194.89.233 with SMTP id br9mr133483wjb.15.1386749885752; Wed, 11 Dec 2013 00:18:05 -0800 (PST) Received: by 10.216.166.133 with HTTP; Wed, 11 Dec 2013 00:18:05 -0800 (PST) In-Reply-To: References: Date: Wed, 11 Dec 2013 08:18:05 +0000 Message-ID: To: chobie Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0102fb5c552b4104ed3dde99 Subject: Re: [PHP-DEV] Proposal: ArraySerializable interface From: leight@gmail.com (Leigh) --089e0102fb5c552b4104ed3dde99 Content-Type: text/plain; charset=ISO-8859-1 On 11 December 2013 01:23, chobie wrote: > Hi, > > I've got an idea for adding common way to convert array from object: > ArraySerializable interface and to allow the changing of existing > array conversion mechanism. ... Currently, the implicit object to array conversion does not work > recursively. This propose changes object to array conversion behaviour > which implements ArraySerializable interface. specifically > ArraySerializable::__toArray method overrides current (array) cast. > > interface ArraySerializable > { > /** @return array */ > public function __toArray(); > } > I have no problems with the proposal in general, however did you see there is an RFC already related to this ( https://wiki.php.net/rfc/object_cast_to_types) that has a patch you might like to reference? I would still like to see the full suite of type-conversion magic methods, I don't see an argument for implementing one and not the others. Not sure if this should come with an interface, for example __toString() does not come with a StringSerializable interface. Perhaps __toArray() / __toString / __toWhatever should all be available without an interface, but also have interfaces that wrap them for the sake of typehinting (which means adding an interface for __toString) --089e0102fb5c552b4104ed3dde99--