Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52946 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 6822 invoked from network); 5 Jun 2011 16:43:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2011 16:43:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=pierre.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=pierre.php@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pierre.php@gmail.com X-Host-Fingerprint: 74.125.82.170 mail-wy0-f170.google.com Received: from [74.125.82.170] ([74.125.82.170:33469] helo=mail-wy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F7/52-26000-522BBED4 for ; Sun, 05 Jun 2011 12:43:17 -0400 Received: by wyb34 with SMTP id 34so2656796wyb.29 for ; Sun, 05 Jun 2011 09:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=rPwGdu8T778jv6L639DHsm2JiRmSYkNYLpl7ZY6dJp8=; b=UULQALXOcGL1IlVTYfcvzZwWm5n7oy3Ar3ktsaefSdb6pRmx7xlbhQ/y7lYwwbMs6a wLNhu4xihDM20GFGfu7BJx4eK+uT2KtjGLuKGjjfqpdWMNXYwDiepJ12MoLdHHj3gjVz xxGbSRAyboF4+fSeauV+6txkDTPvoD7buW18w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=AX3g7HcIBGTaTCQ6omuVAwzvY2W2LzrNuj7gJIqaMvQjcIGkUp2xqRLPhR+0fKx5Te GBH81fF/WA7Zu/en29CsX0p6zcSV+DJQV6TB7NgzdLuNN+IaddO7ZSpBj3CtRwjT2n1x Xrn3+fwRdHJJNEgM17x7jGhS3URgn+LgFg1Rc= MIME-Version: 1.0 Received: by 10.216.28.200 with SMTP id g50mr3760443wea.92.1307292174156; Sun, 05 Jun 2011 09:42:54 -0700 (PDT) Received: by 10.216.253.168 with HTTP; Sun, 5 Jun 2011 09:42:52 -0700 (PDT) In-Reply-To: References: Date: Sun, 5 Jun 2011 18:42:52 +0200 Message-ID: To: Felipe Pena Cc: internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] $arr = array('Hello', 'world'); $arr(); From: pierre.php@gmail.com (Pierre Joye) +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 wh= ich > points to an interesting feature that I think makes sense for us, since w= e > 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 { > =A0 public function world($x) { > =A0 =A0 =A0echo "Hello, $x\n"; return $this; > =A0 } > } > > $f =3D array('Hello','world'); > var_dump($f('you')); > > $f =3D 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=3D47160 > [2] - http://felipe.ath.cx/diff/fr47160.diff > phpt: http://felipe.ath.cx/diff/fr47160.phpt > > -- > Regards, > Felipe Pena > --=20 Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org