Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:105596 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55700 invoked from network); 5 May 2019 17:56:34 -0000 Received: from unknown (HELO wout2-smtp.messagingengine.com) (64.147.123.25) by pb1.pair.com with SMTP; 5 May 2019 17:56:34 -0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id DD2202D9; Sun, 5 May 2019 10:59:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 05 May 2019 10:59:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=benramsey.com; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm1; bh=T b+brJZuyE+yLcsOE4ZaLVYvQncruJt+jIJRUZKBcmI=; b=ZuvQbm5Kg6Ia6Vdk/ NTC6vXiXgTHu2S9TuiTNjK3X3RXzDGmmDY7qiLu6TNPgJP2wGzsbNBVGQdZY1enw bwr6+H8ylp0LzXcu8355HPmIAeyFKiWLfiSc/Pifjm5iXwdvwllPL0aBy7orh8dk 0kkNhVFDf2EYjjGGwdbkSvv8n1asMHTaiZt/u+T01emB2sjuLp/v1M9B3lNv0ja+ ebCFN/UAS3PP4m/9E1USxM+qG4FGSvrL9KINSEVDEXKCSDseEfitWsxm+Jf3txnw 1kBMSRhPzlod5wn1dmdnIWGdTVMQpP8w+fFGazZtXr6AuvxDrFWSbYrf3H9LwAus pzEeA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=Tb+brJZuyE+yLcsOE4ZaLVYvQncruJt+jIJRUZKBc mI=; b=5yOR5tD+T6ssYZGtbJ1+ebgLUJx9Lqi7fcgfHuLo6u/mrGL1DOFlQsS/M R/abT7wt/qYu/cXLK3n4onRXYLWjvbXQ0PmUDd7LII5bQejk6zJeCqUiUKZ0fMsq ZTHtLUODrnafZX/huCCcuirBGD83jXI/sNSvwJqvR9LppWXymzxL9WxcK7sU64ya zn3d7Xpb18dKWutC7HrORqU4biR5FcCboSdYWN68PjtP6SQqtshCbCEhBBN6TWGj JpS3YPbNQSbd6GjnyvxZeLU7eVP5/iCjDXBQHEw8yRhP02sd3JaV70fZzV8Y6boW u3n9SO9jkHcD4a838NXHzMeuE0xrw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrjeehgdeklecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurheptggguffhofgjfffgkfhfvfesthhqmh dthhdtjeenucfhrhhomhepuegvnhcutfgrmhhsvgihuceosggvnhessggvnhhrrghmshgv hidrtghomheqnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucfkphepleeirdeiud drudejtddrhedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegsvghnsegsvghnrhgrmhhs vgihrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from [10.10.42.46] (h96-61-170-50.lvrgtn.dsl.dynamic.tds.net [96.61.170.50]) by mail.messagingengine.com (Postfix) with ESMTPA id D6929E4544; Sun, 5 May 2019 10:59:57 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) X-Mailer: iPhone Mail (16E227) In-Reply-To: Date: Sun, 5 May 2019 09:59:57 -0500 Cc: internals@lists.php.net Content-Transfer-Encoding: quoted-printable Message-ID: <384B1934-FC7A-414D-BC31-E5521B2F0E17@benramsey.com> References: To: Steven Wade Subject: Re: [PHP-DEV] Proposal for a RFC From: ben@benramsey.com (Ben Ramsey) > On May 4, 2019, at 09:58, Steven Wade wrote: >=20 > Hi Internals team! >=20 > I have an idea for a feature that I'd love to see in the language one day a= nd wanted to run the idea by you all.=20 >=20 > The idea is to add a new magic method "__toArray()" that would allow a dev= eloper to specifiy how a class is cast to an array. The idea is the same men= tality of __toString(), but, for arrays. >=20 > I would personally love this feature and those I've run it by were also ex= cited by the idea. So I'm soliciting feedback in hopes that things go well a= nd I can officially write the RFC. As for implementation, Sara Golemon is aw= esome and while chatting a few months back, knocked out a proof-of-concept i= mplementation . There's still work to be done if this proposal gets to the RFC phase, bu= t again, just gauging interest here. >=20 > I appreciate any feedback you all can provide. >=20 > Thanks, >=20 > - Steven Wade Using existing language functionality, would it satisfy the similar needs if= you implement IteratorAggregate and return an ArrayIterator from the getIte= rator() method? Obviously, the (array) cast wouldn=E2=80=99t use this, but y= ou could do $object->getIterator()->getArrayCopy(). I=E2=80=99m not against the proposal. I=E2=80=99m mainly asking if there are= other ways in the language today to accomplish similar things. I would pref= er to see interfaces used over more magic methods (something like ArraySeria= lizable). -Ben=