Skip to content

Commit 2832a00

Browse files
committed
Fix phpcbf crash in UnnecessaryNamespaceUsageSniff when class name is empty, fixes #212
1 parent 036ac8a commit 2832a00

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,12 @@ protected function getUseStatements(File $phpcsFile, int $start, int $end): arra
230230
$end,
231231
true
232232
);
233-
$useEnd = $phpcsFile->findNext(
233+
234+
if (0 === $classNameEnd) {
235+
break;
236+
}
237+
238+
$useEnd = $phpcsFile->findNext(
234239
[
235240
T_SEMICOLON,
236241
T_COMMA,

0 commit comments

Comments
 (0)