atom feed35 messages in net.php.lists.internalsRe: [PHP-DEV] Re: $arr = array('Hello...
FromSent OnAttachments
Felipe PenaJun 5, 2011 8:52 am 
Benjamin EberleiJun 5, 2011 8:57 am 
Felipe PenaJun 5, 2011 9:20 am 
Etienne KneussJun 5, 2011 9:41 am 
Pierre JoyeJun 5, 2011 9:42 am 
Marcel EsserJun 5, 2011 9:48 am 
Ferenc KovacsJun 5, 2011 11:16 am 
Stas MalyshevJun 5, 2011 12:49 pm 
Zeev SuraskiJun 5, 2011 12:52 pm 
Pierre JoyeJun 5, 2011 12:54 pm 
Johannes SchlüterJun 5, 2011 12:55 pm 
Felipe PenaJun 5, 2011 1:01 pm 
Zeev SuraskiJun 5, 2011 1:09 pm 
Felipe PenaJun 5, 2011 1:34 pm 
Stas MalyshevJun 5, 2011 1:50 pm 
Felipe PenaJun 5, 2011 2:15 pm 
Hannes LandeholmJun 5, 2011 2:49 pm 
Stas MalyshevJun 5, 2011 3:15 pm 
Dmitry StogovJun 6, 2011 12:23 am 
David ZülkeJun 6, 2011 3:53 am 
Julien PauliJun 6, 2011 6:21 am 
Hannes MagnussonJun 6, 2011 7:33 am 
Matthew Weier O'PhinneyJun 6, 2011 8:54 am 
Matthew Weier O'PhinneyJun 6, 2011 9:31 am 
Christopher JonesJun 6, 2011 1:50 pm 
Felipe PenaJun 6, 2011 2:49 pm 
Christian KapsJun 8, 2011 4:38 am 
Felipe PenaJun 8, 2011 4:57 am 
Christian KapsJun 8, 2011 5:11 am 
Felipe PenaJun 8, 2011 5:46 am 
Jordi BoggianoJun 8, 2011 6:39 am 
Christian KapsJun 8, 2011 6:41 am 
Christian KapsJun 8, 2011 6:48 am 
Rune KaagaardJul 14, 2011 2:03 pm 
Felipe PenaJul 14, 2011 2:13 pm 
Subject:Re: [PHP-DEV] Re: $arr = array('Hello', 'world'); $arr();
From:Felipe Pena (feli@gmail.com)
Date:Jun 8, 2011 4:57:25 am
List:net.php.lists.internals

Hi,

2011/6/8 Christian Kaps <chri@mohiva.com>

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?

Yes, the same rules.