Roave / BetterReflection

:crystal_ball: Better Reflection is a reflection API that aims to improve and provide more features than PHP's built-in reflection API.
MIT License
1.19k stars 131 forks source link

ReflectionFunction::fromClosure does not work for first-class callables (throw NoClosureOnLine exception) #1363

Open MartinMystikJonas opened 1 year ago

MartinMystikJonas commented 1 year ago

This code throws NoClosureOnLine exception

$closure = (new Something())->foo(...);
ReflectionFunction::createFromClosure($closure);

it seems ReflectionFunction::createFromClosure does not support first class callables. Is there any other way to get reflection of given closure created by first-class callable?

Ocramius commented 1 year ago

I think the code needs to be expanded to include that scenario: when this code was written, first class callables didn't really exist

ondrejmirtes commented 11 months ago

FYI the fix is no longer needed for this use case. They solved it differently.

Ocramius commented 11 months ago

@ondrejmirtes so ReflectionFunction::createFromClosure(foo(...)) works now? :P

MartinMystikJonas commented 11 months ago

@Ocramius In our use case we simply used native reflection

Ocramius commented 11 months ago

That's fine then, but it means this library is still affected 😁