Re: Call closure stored as object property directly without use of temporary variable

From: Date: Sat, 08 Dec 2012 22:36:04 +0000
Subject: Re: Call closure stored as object property directly without use of temporary variable
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-64201@lists.php.net to get a copy of this message
Adam, On 12/8/12 4:48 PM, Adam Jon Richardson wrote:
call closures that are stored as object properties directly without having to make use of a temporary variable. ...
$o = new stdClass(); $o->func = function(){
     return 'Yes!';
}; $o->func();
The following expression avoids PHP's dilemma of distinguishing prop/method, but fails because you can't execute an expression: ($o->func)(); Similarly if $a is a Closure, $a() works but ($a)() fails. If these could be made to work, would it break BC? And *should* they be made to work? Steve Clay -- http://www.mrclay.org/

« previous php.internals (#64201) next »