Re: [RFC] Closure::call and Function Referencing as Closures
| From: | Andrea Faulds | Date: | Wed, 06 Aug 2014 15:08:02 +0000 |
| Subject: | Re: [RFC] Closure::call and Function Referencing as Closures | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-76397@lists.php.net to get a copy of this message | ||
On 6 Aug 2014, at 16:01, Ralph Schindler <ralph@ralphschindler.com> wrote:
> When you put it like this, that further enhances my argument for adding
> a call() and/or a bindCall(). Having to rely on __invoke() means
> you're coding around and relying on an implementation detail, as opposed
> to the class's published API.
__invoke *is* in the published API, it’s just not seen properly by Reflection or the docs. Yes,
internally it’s implemented weirdly, but it is part of the API proper.
> It would be nice to be able to call closure in an object oriented way,
> in addition to the language-level call $func() and the
> functional/procedural way to call it call_user_func($func), after all, at current it seems
> OO-isms are more rampant in PHP than other programming paradigms.
Use () or __invoke(). Unfortunately you can’t do ->foo()() just now, sure, but I believe
Nikita’s Uniform Variable Syntax fixes that, so it’s not a problem. ->call doesn’t cater to
this use case.
--
Andrea Faulds
http://ajf.me/