Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61196 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60693 invoked from network); 13 Jul 2012 13:41:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Jul 2012 13:41:44 -0000 X-Host-Fingerprint: 208.107.183.205 host-205-183-107-208.midco.net Date: Fri, 13 Jul 2012 09:41:43 -0400 Received: from [208.107.183.205] ([208.107.183.205:25270] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/F5-17670-79520005 for ; Fri, 13 Jul 2012 09:41:43 -0400 Message-ID: <94.F5.17670.79520005@pb1.pair.com> To: internals@lists.php.net References: <4FFEFBB3.7090507@sugarcrm.com> <4FFEFD81.6020404@lerdorf.com> <4FFEFF71.2060202@sugarcrm.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, Stas Malyshev wrote: > > 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). > > It doesn't make the life of the caller easier. On the contrary, it makes > each call into a minefield - will it blow up with a system-level error > when you call it? I think you're reading way more into this, or didn't read the same sample I did from Anthony. foreach() allows an array or a Traversable object. The proposal is to create a typehint that spans the set of (array + Traversable) so that folks don't have to do a check in each and every method where they want to accept both so they can iterate. I've written the same or similar checks to what Anthony posted hundreds of times, and seen it many, many more than that. -- 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