Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53205 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49811 invoked from network); 8 Jun 2011 11:39:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jun 2011 11:39:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=christian.kaps@mohiva.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=christian.kaps@mohiva.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mohiva.com from 178.63.228.54 cause and error) X-PHP-List-Original-Sender: christian.kaps@mohiva.com X-Host-Fingerprint: 178.63.228.54 elvis.mohiva.com Linux 2.6 Received: from [178.63.228.54] ([178.63.228.54:53627] helo=elvis.mohiva.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B0/10-48516-26F5FED4 for ; Wed, 08 Jun 2011 07:39:15 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by elvis.mohiva.com (Postfix) with ESMTP id D88361D24013 for ; Wed, 8 Jun 2011 13:39:10 +0200 (CEST) X-Virus-Scanned: amavisd-new at mohiva.com Received: from elvis.mohiva.com ([127.0.0.1]) by localhost (elvis.mohiva.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id egMAIaqwcctc for ; Wed, 8 Jun 2011 13:39:09 +0200 (CEST) Received: from elvis.mohiva.com (elvis.mohiva.com [178.63.228.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: christian.kaps@mohiva.com) by elvis.mohiva.com (Postfix) with ESMTPSA id 0B9181D24011 for ; Wed, 8 Jun 2011 13:39:09 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 08 Jun 2011 13:39:08 +0200 To: Message-ID: <67f900ce904612afdba7650ccbed6ed4@mohiva.com> X-Sender: christian.kaps@mohiva.com User-Agent: Roundcube Webmail/0.5.2 Subject: Re: $arr =?UTF-8?Q?=3D=20array=28=27Hello=27=2C=20=27world=27=29?= =?UTF-8?Q?=3B=20=24arr=28=29=3B?= From: christian.kaps@mohiva.com (Christian Kaps) Hi, > 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? > what happens if I use this code. class Foo { public $bar; public function __construct() { $this->bar = array($this, 'baz'); $this->bar(); } public function bar() { echo 'bar'; } public function baz() { echo 'baz'; } } new Foo(); What is the output of this snippet? Are there the same rules as for closures? Christian