Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61197 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60772 invoked from network); 13 Jul 2012 13:41:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jul 2012 13:41:46 -0000 X-Host-Fingerprint: 208.107.183.205 host-205-183-107-208.midco.net Date: Fri, 13 Jul 2012 09:41:46 -0400 Received: from [208.107.183.205] ([208.107.183.205:5511] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A4/F5-17670-A9520005 for ; Fri, 13 Jul 2012 09:41:46 -0400 Message-ID: To: internals@lists.php.net References: <4FFEFBB3.7090507@sugarcrm.com> <4FFEFD81.6020404@lerdorf.com> User-Agent: slrn/pre1.0.0-18 (Linux) X-Posted-By: 208.107.183.205 Subject: Re: [PHP-DEV] Iterable Type Hint From: weierophinney@php.net (Matthew Weier O'Phinney) On 2012-07-12, Rasmus Lerdorf wrote: > On 07/12/2012 09:30 AM, Stas Malyshev wrote: > > > Would it be worth while adding a new type hint that checks for this > > > condition? I'd propose Iterable: > > > > I see more and more multiplication of weird ad-hoc type checks. First we > > had "callable", now "traversable", then we invent more and more weird > > functional types with complex logic. I don't like this development at > > all. It's ad-hoc introducing of half-baked, unstandartized, undesigned > > strict typing. Strict typing is not a good idea for PHP, and weird > > strict typing based on complex conditions hidden from the user is even > > worse IMO. > > For non-interchangeable types it is already strict by definition. I > don't see a problem with type hints that make life easier on both the > caller (by generating better error messages) and the callee (by having > to write less boilerplate type verification code). > > You may have a point on the ad-hoc nature of it and that we need to do > it once and for all in a more organized fashion, but the basic premise > looks ok to me. I wouldn't call it ad hoc, actually, but more a recognition of what practices and patterns are now occurring. A few years ago, I'd have type-hinted on array and been done with it. But more and more often, I'm interested in either an array or something Traversable, and I end up with boilerplate just like Anthony had in his original post on this thread. And I see it _everywhere_. -- Matthew Weier O'Phinney Project Lead | matthew@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc