On 2012-07-12, Rasmus Lerdorf <ras...@lerdorf.com> 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 | matt...@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php