BetterReflection icon indicating copy to clipboard operation
BetterReflection copied to clipboard

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

Open MartinMystikJonas opened this issue 1 year ago • 5 comments

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?

MartinMystikJonas avatar Aug 23 '23 08:08 MartinMystikJonas

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

Ocramius avatar Aug 23 '23 08:08 Ocramius

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

ondrejmirtes avatar Nov 15 '23 15:11 ondrejmirtes

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

Ocramius avatar Nov 15 '23 15:11 Ocramius

@Ocramius In our use case we simply used native reflection

MartinMystikJonas avatar Nov 15 '23 15:11 MartinMystikJonas

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

Ocramius avatar Nov 16 '23 00:11 Ocramius