Skip to content

Commit

Permalink
Locator::getClassName returns null if file ends with a return statement
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Oct 13, 2022
1 parent a405e10 commit 64021cb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Locator.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public function getClassName(string $filename) : ?string
}
continue;
}
if ($token[0] === \T_RETURN) {
return null;
}
if (\in_array($token[0], [
\T_CLASS,
\T_ENUM,
Expand All @@ -74,9 +77,6 @@ public function getClassName(string $filename) : ?string
for ($next = $current + 1; $next < $last; $next++) {
if ($tokens[$next] === '{') {
$token = $tokens[$current + 2];
if ( ! isset($token[1])) {
return null;
}
$class = $namespace . '\\' . $token[1];
break 2;
}
Expand Down

0 comments on commit 64021cb

Please sign in to comment.