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

Exception when a route name is a parsable number #448

Open
sorrx opened this issue Dec 20, 2022 · 0 comments
Open

Exception when a route name is a parsable number #448

sorrx opened this issue Dec 20, 2022 · 0 comments

Comments

@sorrx
Copy link

sorrx commented Dec 20, 2022

For Symfony 6.2 a valid Route could be #[Route(path: '/{_locale}/404', name: '404')]
When using the string '404' as array key in the route-collection internally PHP converts that to an integer. So the annotated return type of the route collection "array<string, Route>" is no longer true due to PHP working in such way.
In Extractor/ExposedRouteExtractor.php the

preg_match('#^'.$this->pattern.'$#', $name, $matches);

then fails with an Exception, because it expects a string and not an integer as second parameter.

compare symfony/symfony#48722

Easy fix for the FOSJsRoutingBundle would be a typecast

preg_match('#^'.$this->pattern.'$#', (string)$name, $matches);

which I understand is kind of annoying, given the annotated return-type

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

No branches or pull requests

1 participant