Skip to content

Commit 58fa5ea

Browse files
committed
UselessSemicolonSniff: Fixed internal error
1 parent a3b4e39 commit 58fa5ea

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

SlevomatCodingStandard/Sniffs/PHP/UselessSemicolonSniff.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PHP_CodeSniffer\Sniffs\Sniff;
77
use SlevomatCodingStandard\Helpers\TokenHelper;
88
use function array_key_exists;
9+
use function count;
910
use function in_array;
1011
use const T_ANON_CLASS;
1112
use const T_CLOSE_CURLY_BRACKET;
@@ -148,7 +149,7 @@ private function removeUselessSemicolon(File $phpcsFile, int $semicolonPointer):
148149
} while (true);
149150

150151
$fixEndPointer = $semicolonPointer;
151-
do {
152+
while ($fixEndPointer < count($tokens) - 1) {
152153
if ($tokens[$fixEndPointer + 1]['code'] !== T_WHITESPACE) {
153154
break;
154155
}
@@ -158,7 +159,7 @@ private function removeUselessSemicolon(File $phpcsFile, int $semicolonPointer):
158159
}
159160

160161
$fixEndPointer++;
161-
} while (true);
162+
}
162163

163164
$phpcsFile->fixer->beginChangeset();
164165
for ($i = $fixStartPointer; $i <= $fixEndPointer; $i++) {

0 commit comments

Comments
 (0)