-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] fix conflict with param named class in attribute #40244
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
[Routing] fix conflict with param named class in attribute #40244
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
Can you please rebase+retarget on 5.2 if that's really the target? |
9d6129b
to
0c77083
Compare
Sorry it's my first PR, can you tell me how to correct my PR to be on 5.2? |
0c77083
to
197843d
Compare
I force-pushed on your fork. |
Are we sure that 4.4 is not affected? |
197843d
to
a6b2aaa
Compare
(now targetting 4.4) |
Tx for the help. |
I need to understand why it does not work in PHP7.1 on multiline Attributes |
src/Symfony/Component/Routing/Tests/Fixtures/Attributes/FooAttributes.php
Outdated
Show resolved
Hide resolved
I think there are tests that can only be done in PHP8.
is not recognized as a valid instruction in PHP7.X. With |
correct. You can add the |
Thank you for working on this. However, I'm not convinced that bracket counting is the way we should fix this. We already have a piece of code in that file that handles incorrect diff --git a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php
--- a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php (revision eeed8c8e847b81ea5d16685395e85a1df9077449)
+++ b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php (date 1613917175487)
@@ -100,20 +100,8 @@
$nsTokens[T_NAME_QUALIFIED] = true;
}
- $openBrackets = 0;
for ($i = 0; isset($tokens[$i]); ++$i) {
$token = $tokens[$i];
- if (80000 <= \PHP_VERSION_ID) {
- if (\T_ATTRIBUTE === ($token[0] ?? 0) || ($openBrackets > 0 && '[' === $token)) {
- ++$openBrackets;
- }
- if ($openBrackets > 0 && ']' === $token) {
- --$openBrackets;
- }
- if ($openBrackets > 0) {
- continue;
- }
- }
if (!isset($token[1])) {
continue;
@@ -146,6 +134,15 @@
break;
}
}
+ for ($j = $i + 1; isset($tokens[$j]); ++$j) {
+ if (':' === $tokens[$j]) {
+ $skipClassToken = true;
+ break;
+ }
+ if (!\in_array($tokens[$j][0], [\T_WHITESPACE, \T_DOC_COMMENT, \T_COMMENT])) {
+ break;
+ }
+ }
if (!$skipClassToken) {
$class = true; |
With this test I check if the
Normally it shouldn't have side effects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make fabbot happy. Apart from that, I think we're good. Thank you for working on this issue.
c6432c8
to
27e6348
Compare
27e6348
to
27bba68
Compare
Thank you @nlhommet. |
Fix conflict with AnnotationFileLoader and class PHP8 Attribute with param named "class"