Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53002 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89642 invoked from network); 6 Jun 2011 07:24:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Jun 2011 07:24:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.199.177.89 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 212.199.177.89 il-mr1.zend.com Received: from [212.199.177.89] ([212.199.177.89:49879] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D5/81-13071-0A08CED4 for ; Mon, 06 Jun 2011 03:24:17 -0400 Received: from il-gw1.zend.com (unknown [10.1.1.22]) by il-mr1.zend.com (Postfix) with ESMTP id 31F3D606DB; Mon, 6 Jun 2011 10:23:11 +0300 (IDT) Received: from ws.home (10.1.10.40) by il-ex2.zend.net (10.1.1.22) with Microsoft SMTP Server id 14.1.255.0; Mon, 6 Jun 2011 10:23:55 +0300 Message-ID: <4DEC809C.5000306@zend.com> Date: Mon, 6 Jun 2011 11:24:12 +0400 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: Felipe Pena CC: internals References: In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.1.10.40] Subject: Re: [PHP-DEV] $arr = array('Hello', 'world'); $arr(); From: dmitry@zend.com (Dmitry Stogov) Hi Felipe, I like the idea. It makes indirect method calls less expensive. I would add a hint to specializer, to eliminate small overhead for regular function calls. } else if (OP1_TYPE != IS_CONST && EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) && zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) { Thanks. Dmitry. On 06/05/2011 07: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 >