Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87194 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1214 invoked from network); 16 Jul 2015 09:26:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2015 09:26:56 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.42 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.42 mail-wg0-f42.google.com Received: from [74.125.82.42] ([74.125.82.42:34305] helo=mail-wg0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EC/20-32891-ED877A55 for ; Thu, 16 Jul 2015 05:26:55 -0400 Received: by wgkl9 with SMTP id l9so53365073wgk.1 for ; Thu, 16 Jul 2015 02:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:to:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=WS/6qTt1QbghSBEwmadeLnALAPcQj8Ii+tFQIzCAhiA=; b=KRFyuw6Tm+kXdy3pHIOR3MYXVhZdMdcwVqEthg0hb55xfkOWCQFS0pQ0nXEXZAL339 CcsXM0Yh9kNUz+gPqQlHUsbfCROkQrLD2BDl4WJ38p+u1pJsIbmeY4TejErt5BRfJwPd 1jfL/Sv84yI+306fS0D63B/KVX9Rpy6HxZH52IER51t67CIp7zIkUDkMVWIcv4f14GBM sYutImnjFEJGjUDt2WfR+I3pc9UIqE0/910tenDxvVSEHkof3HhAjklgV59au2Pm+n9R 5ShOAIxmkIpaQa8zl8Gqrkdu3gLMHlpgFltTJz0HQSaUXT5PTn6r4PJYeH63Jj9MDMvh wpvw== X-Received: by 10.181.11.229 with SMTP id el5mr4861383wid.40.1437038811686; Thu, 16 Jul 2015 02:26:51 -0700 (PDT) Received: from [192.168.0.136] ([62.189.198.114]) by smtp.googlemail.com with ESMTPSA id ul1sm11966929wjc.30.2015.07.16.02.26.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 02:26:50 -0700 (PDT) References: <1436967838.8300.16.camel@kuechenschabe> <47DA8928-322C-4869-809F-BABDCA20FFB5@gmail.com> To: PHP Internals Message-ID: <55A778C7.1040100@gmail.com> Date: Thu, 16 Jul 2015 10:26:31 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------060607030409010308080004" Subject: Re: [PHP-DEV] Consolidation of Traversable and array operations From: rowan.collins@gmail.com (Rowan Collins) --------------060607030409010308080004 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Benjamin Eberlei wrote on 15/07/2015 21:19: > > > On Wed, Jul 15, 2015 at 9:53 PM, Rowan Collins > > wrote: > > On 15 July 2015 20:39:05 GMT+01:00, Levi Morrison > wrote: > >Do note that the union types RFC would also alleviate some of this > >pain for user-land functions, since `array | Traversable` would cover > >the required access pattern. I think this is a superior approach > >myself, but I may be a bit biased as I am authoring that proposal: > >https://wiki.php.net/rfc/union_types > > I like the idea of union types in general, but have always felt > that a typehint of Traversable should accept arrays as a matter of > course. The only thing such a typehint guarantees is that foreach > will work (there are no methods defined that can be called > directly), and an array meets that condition. The only difference > I can see is in the passing / mutability behaviour of objects vs > non-objects. > > > But instanceof and anything related to Reflection or get_class or > relevant code will fail on array. Ah, yes, I hadn't thought of reflection type things. I don't think instanceof would be a problem, because checking for any class or interface other than Traversable would correctly return false; not sure if it would make sense for "array() instanceof Traversable" to return true or not... --------------060607030409010308080004--