Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52941 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94354 invoked from network); 5 Jun 2011 15:58:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2011 15:58:06 -0000 Authentication-Results: pb1.pair.com header.from=kontakt@beberlei.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=kontakt@beberlei.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain beberlei.de from 178.77.98.152 cause and error) X-PHP-List-Original-Sender: kontakt@beberlei.de X-Host-Fingerprint: 178.77.98.152 lvps178-77-98-152.dedicated.hosteurope.de Linux 2.6 Received: from [178.77.98.152] ([178.77.98.152:53338] helo=beberlei.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/20-26000-C87ABED4 for ; Sun, 05 Jun 2011 11:58:05 -0400 Received: from benny-pc (koln-4d0b5d76.pool.mediaWays.net [77.11.93.118]) by beberlei.de (Postfix) with ESMTPSA id 7D8846E0911B for ; Sun, 5 Jun 2011 17:58:01 +0200 (CEST) Date: Sun, 5 Jun 2011 17:57:59 +0200 To: internals@lists.php.net Message-ID: <20110605175759.61a11a4a@benny-pc> In-Reply-To: References: X-Mailer: Claws Mail 3.7.8 (GTK+ 2.24.4; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] $arr = array('Hello', 'world'); $arr(); From: kontakt@beberlei.de (Benjamin Eberlei) That can lead to quite a bit of simplifications in code where you now have to check for is_array/is_callable/instanceof Closure and such. I like it. On Sun, 5 Jun 2011 12:52:45 -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 > > -- > Regards, > Felipe Pena