Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[6.2][HttpKernel] ReflectionFunction causes "Attribute Route cannot target function" #46916

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

Closed
weaverryan opened this issue Jul 12, 2022 · 1 comment

Comments

@weaverryan
Copy link
Member

Symfony version(s) affected

6.2.x-dev

Description

Hi!

Currently, the new _controller_reflectors in ControllerEvent - https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/HttpKernel/Event/ControllerEvent.php#L64-L66 - is causing the Route attribute to break.

From the MakerBundle test suite, while testing a normal [Route()] above a traditional controller action method:

Uncaught PHP Exception Error: "Attribute "Symfony\Component\Routing\Annotation\Route" cannot target function (allowed targets: class, method)" at /.../vendor/symfony/http-kernel/Event/ControllerEvent.php line 82

The problem seems to come from the ReflectionFunction... which seems to confuse the attributes system.

Cheers!

How to reproduce

In Symfony 6.2, create a #[Route] and then go to the page for that route.

Possible Solution

I'm not familiar with the implications of using ReflectionFunction vs ReflectionMethod, but it seems we need ReflectionMethod for the attributes to be instantiated correctly?

Additional Context

No response

@nicolas-grekas
Copy link
Member

Fixed by #46880, which is pending votes ;)

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

4 participants