> Le 21 oct. 2021 à 01:12, Dylan K. Taylor <dkta...@pmmp.io> a écrit :
> 
> Hi all, 
> 
> Given the addition of Closure::fromCallable() and the upcoming first-class 
> callable syntax in 8.1, it seems slightly problematic that there's no simple 
> way to tell by reflection if a Closure refers to an anonymous function or 
> not. ReflectionFunctionAbstract::isClosure() (perhaps somewhat misleadingly) 
> returns whether the closure is literally a \Closure instance, so it's not 
> useful for this purpose. 
> 
> The only way to do this currently (that I know about) is to check if the name 
> of the function contains "{closure}", which is a bit unpleasant and depends 
> on undocumented behaviour. 
> 
> I'm proposing the addition of ReflectionFunctionAbstract::isAnonymous(), 
> which would fill this use case, and may be able to offer an implementation. 
> 
> Thanks, 
> Dylan Taylor. 
> 
> 
> -- 
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
> 


Hi,

Per the manual [1], Closure::fromCallable() “creates and returns a new 
anonymous function”. I guess that this might not match your notion of 
“anonymous function”?

Therefore, I am asking for clarification: What practical distinction do you 
make between ”an instance of Closure” and “an anonymous function”, and why does 
this distinction matter?

[1]: https://www.php.net/manual/en/closure.fromcallable.php 
<https://www.php.net/manual/en/closure.fromcallable.php>

—Claude

Reply via email to