8000 [Routing] Finish annotation loader taking a class constant as a begin… · src-run/symfony@8d4f35d · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d4f35d

Browse files
[Routing] Finish annotation loader taking a class constant as a beginning of a class name
1 parent 43c7f9b commit 8d4f35d

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ protected function findClass($file)
9696
$token = $tokens[$i];
9797

9898
if (!isset($token[1])) {
99-
$class = false;
100-
10199
continue;
102100
}
103101

@@ -114,7 +112,24 @@ protected function findClass($file)
114112
}
115113

116114
if (T_CLASS === $token[0]) {
117-
$class = true;
115+
// Skip usage of ::class constant
116+
$isClassConstant = false;
117+
for ($j = $i - 1; $j > 0; --$j) {
118+
if (!isset($tokens[$j][1])) {
119+
break;
120+
}
121+
122+
if (T_DOUBLE_COLON === $tokens[$j][0]) {
123+
$isClassConstant = true;
124+
break;
125+
} elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) {
126+
break;
127+
}
128+
}
129+
130+
if (!$isClassConstant) {
131+
$class = true;
132+
}
118133
}
119134

120135
if (T_NAMESPACE === $token[0]) {

src/Symfony/Component/Routing/Tests/Fixtures/AnnotatedClasses/FooTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ public function doBar()
1010
if (true) {
1111
}
1212
}
13-
}
13+
}

0 commit comments

Comments
 (0)
0