Re: [RFC] Closure::call and Function Referencing as Closures
| From: | Andrea Faulds | Date: | Mon, 04 Aug 2014 01:01:08 +0000 |
| Subject: | Re: [RFC] Closure::call and Function Referencing as Closures | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-76328@lists.php.net to get a copy of this message | ||
On 4 Aug 2014, at 01:53, Thomas Bley <mails@thomasbley.de> wrote:
> from userland perspective, I would prefer to open the Closure constructor instead of adding new
> syntax:
>
> $qux = new FooBar(3);
> // $func = &FooBar::getStatic;
> $func = new Closure(array('FooBar', 'getStatic'));
> $func($qux); // 3
You can actually do that already in a convoluted way:
$func = (new ReflectionMethod(“FooBar::getStatic”)->getClosure());
Though it must be explicitly bound in the case of a non-static method.
--
Andrea Faulds
http://ajf.me/