Re: [RFC] Support for <func>::function syntax
| From: | Marco Pivetta | Date: | Sun, 08 Nov 2020 14:50:06 +0000 |
| Subject: | Re: [RFC] Support for <func>::function syntax | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112205@lists.php.net to get a copy of this message | ||
Hey Michael,
<http://ocramius.github.com/>
On Sun, Nov 8, 2020 at 9:38 AM Michael Voříšek - ČVUT FEL <
vorismi3@fel.cvut.cz> wrote:
> Hi,
>
> what about resolving directly to Closure?
>
> strtoupper::function === \Closure::fromCallable('strtoupper').
>
> $this->method::function === \Closure::fromCallable([$this, 'method']).
>
> With kind regards / Mit freundlichen Grüßen / S přátelským pozdravem,
>
From a tooling point of view, it would be super-interesting to get a FQN of
the function, instead of a closure (which is just
\Closure).
In this snippet, I'd expect the output to be foo\bar\baz\taz:
```php
<?php
use function foo\bar\baz;
echo baz\taz::function;
```
Not sure if string is enough, but it worked really well for ::class,
for which tools like psalm now have a dedicated class-string type :-)
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/