Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52961 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 58861 invoked from network); 5 Jun 2011 19:56:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2011 19:56:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 unknown Received: from [217.114.211.66] ([217.114.211.66:38711] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 35/4C-26000-A5FDBED4 for ; Sun, 05 Jun 2011 15:56:12 -0400 Received: from [192.168.2.230] (ppp-93-104-38-223.dynamic.mnet-online.de [93.104.38.223]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id E48CA720C4; Sun, 5 Jun 2011 21:56:06 +0200 (CEST) To: Felipe Pena Cc: internals In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Sun, 05 Jun 2011 21:56:05 +0200 Message-ID: <1307303765.1767.394.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.2 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] $arr = array('Hello', 'world'); $arr(); From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi, recently I was surprised this didn't work. so +1 from me. johannes On Sun, 2011-06-05 at 12:52 -0300, Felipe Pena wrote: > Hi all, > 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. > > So, I wrote a patch [2] that allow such behavior to be consistent with > arrays. See some examples: > > class Hello { > public function world($x) { > echo "Hello, $x\n"; return $this; > } > } > > $f = array('Hello','world'); > var_dump($f('you')); > > $f = array(new Hello, 'foo'); > $f(); > > All such calls match with the call_user_func() behavior related to magic > methods, static & non-static methods. > > The array to be a valid callback should be a 2-element array, and it must be > for the first element object/string and for the second string only. (just > like our zend_is_callable() check and opcodes related to init call) > > Any thoughts? > > [1] - http://bugs.php.net/bug.php?id=47160 > [2] - http://felipe.ath.cx/diff/fr47160.diff > phpt: http://felipe.ath.cx/diff/fr47160.phpt >