function UselessSemicolonSniff::checkMultipleSemicolons
1 call to UselessSemicolonSniff::checkMultipleSemicolons()
- UselessSemicolonSniff::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ PHP/ UselessSemicolonSniff.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ PHP/ UselessSemicolonSniff.php, line 50
Class
Namespace
SlevomatCodingStandard\Sniffs\PHPCode
private function checkMultipleSemicolons(File $phpcsFile, int $semicolonPointer) : void {
$tokens = $phpcsFile->getTokens();
$previousPointer = TokenHelper::findPreviousEffective($phpcsFile, $semicolonPointer - 1);
if ($tokens[$previousPointer]['code'] !== T_SEMICOLON) {
return;
}
$possibleEndScopePointer = TokenHelper::findNextLocal($phpcsFile, T_CLOSE_PARENTHESIS, $semicolonPointer + 1);
if ($possibleEndScopePointer !== null && $tokens[$possibleEndScopePointer]['parenthesis_opener'] < $semicolonPointer && array_key_exists('parenthesis_owner', $tokens[$possibleEndScopePointer]) && $tokens[$tokens[$possibleEndScopePointer]['parenthesis_owner']]['code'] === T_FOR) {
return;
}
$fix = $phpcsFile->addFixableError('Useless semicolon.', $semicolonPointer, self::CODE_USELESS_SEMICOLON);
if (!$fix) {
return;
}
$this->removeUselessSemicolon($phpcsFile, $semicolonPointer);
}