Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52947 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10659 invoked from network); 5 Jun 2011 16:49:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2011 16:49:13 -0000 Authentication-Results: pb1.pair.com header.from=marcel.esser@croscon.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=marcel.esser@croscon.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain croscon.com from 66.46.182.54 cause and error) X-PHP-List-Original-Sender: marcel.esser@croscon.com X-Host-Fingerprint: 66.46.182.54 relay.ihostexchange.net Windows 2000 SP4, XP SP1 Received: from [66.46.182.54] ([66.46.182.54:27856] helo=relay.ihostexchange.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1E/23-26000-383BBED4 for ; Sun, 05 Jun 2011 12:49:08 -0400 Received: from [192.168.1.120] (76.111.6.201) by smtp.ihostexchange.net (66.46.182.50) with Microsoft SMTP Server (TLS) id 8.3.137.0; Sun, 5 Jun 2011 12:49:05 -0400 To: internals@lists.php.net In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Date: Sun, 5 Jun 2011 12:49:04 -0400 Message-ID: <1307292544.4040.1.camel@pandastation> MIME-Version: 1.0 X-Mailer: Evolution 2.28.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] $arr = array('Hello', 'world'); $arr(); From: marcel.esser@croscon.com (Marcel Esser) On Sun, 2011-06-05 at 12:42 -0400, Pierre Joye wrote: > +1, very good job! > > On Sun, Jun 5, 2011 at 5:52 PM, 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 > > > > > > -- > Pierre > > @pierrejoye | http://blog.thepimp.net | http://www.libgd.org > This is a very good idea. -- Marcel Esser VP/Engineering, CROSCON Washington, D.C. Office @: marcel.esser@croscon.com office.us +1 (202) 470-6090 mobile.us +1 (202) 250-1988 mobile.de +49 (0)176 391 226 23