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

Skip to content

Commit 197843d

Browse files
nlhommetnicolas-grekas
authored andcommitted
[Routing] fix conflict with param named class in attribure
1 parent 978a9b8 commit 197843d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,20 @@ protected function findClass(string $file)
9898
$nsTokens[\T_NAME_QUALIFIED] = true;
9999
}
100100

101+
$openBrackets = 0;
101102
for ($i = 0; isset($tokens[$i]); ++$i) {
102103
$token = $tokens[$i];
104+
if (80000 <= \PHP_VERSION_ID) {
105+
if (\T_ATTRIBUTE === ($token[0] ?? 0) || ($openBrackets > 0 && '[' === $token)) {
106+
++$openBrackets;
107+
}
108+
if ($openBrackets > 0 && ']' === $token) {
109+
--$openBrackets;
110+
}
111+
if ($openBrackets > 0) {
112+
continue;
113+
}
114+
}
103115

104116
if (!isset($token[1])) {
105117
continue;

0 commit comments

Comments
 (0)