Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53043 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10664 invoked from network); 6 Jun 2011 16:31:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2011 16:31:54 -0000 X-Host-Fingerprint: 208.107.178.23 host-23-178-107-208.midco.net Date: Mon, 06 Jun 2011 12:31:50 -0400 Received: from [208.107.178.23] ([208.107.178.23:14603] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/B2-23189-2F00DED4 for ; Mon, 06 Jun 2011 12:31:50 -0400 Message-ID: <2C.B2.23189.2F00DED4@pb1.pair.com> To: internals@lists.php.net References: User-Agent: slrn/pre1.0.0-18 (Linux) X-Posted-By: 208.107.178.23 Subject: Re: [PHP-DEV] $arr = array('Hello', 'world'); $arr(); From: weierophinney@php.net (Matthew Weier O'Phinney) On 2011-06-06, Hannes Magnusson wrote: > On Sun, Jun 5, 2011 at 17:52, Felipe Pena wrote: > > Reading our bug tracker I noticed a good feature request [1] from 2009 which > > points to an interesting feature that I think makes sense for us, since we > > are now working with $f() using objects and strings, and the array('class', > > 'method') is an old known for call_user_func()-like functions. > > I like it. > > I also think we should implement "callable" typehint. > A lot of framworks are now adopting Closure as a typehint for that, > which is annoying due to the fact you have to wrap anything else in a > closure just to pass that typehint. Agreed. It's even more problematic because the manual clearly states that the "Closure" class is considered an implementation detail, and should not be relied upon. As such, if the implementation changes in the future, all those frameworks/libraries will need to refactor. And for those that try to do it "right," they need to jump through a fair bit of logic (test for object or string, test for array) in order to hand off execution properly. > Essentially the callable typehint would be the same as > is_callable($arg, true); > > That means I can pass in any string with a function name, an array > (with class+methodname), and a closure. +1. -- 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