Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
MartinMystikJonas opened this issue Aug 23, 2023 · 5 comments

Comments

@MartinMystikJonas
Copy link

MartinMystikJonas commented Aug 23, 2023

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
Copy link
Member

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
Copy link
Contributor

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

@Ocramius
Copy link
Member

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

@MartinMystikJonas
Copy link
Author

@Ocramius In our use case we simply used native reflection

@Ocramius
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants