Skip to content

Commit 64021cb

Browse files
committed
Locator::getClassName returns null if file ends with a return statement
1 parent a405e10 commit 64021cb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Locator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public function getClassName(string $filename) : ?string
6565
}
6666
continue;
6767
}
68+
if ($token[0] === \T_RETURN) {
69+
return null;
70+
}
6871
if (\in_array($token[0], [
6972
\T_CLASS,
7073
\T_ENUM,
@@ -74,9 +77,6 @@ public function getClassName(string $filename) : ?string
7477
for ($next = $current + 1; $next < $last; $next++) {
7578
if ($tokens[$next] === '{') {
7679
$token = $tokens[$current + 2];
77-
if ( ! isset($token[1])) {
78-
return null;
79-
}
8080
$class = $namespace . '\\' . $token[1];
8181
break 2;
8282
}

0 commit comments

Comments
 (0)