function UselessSemicolonSniff::checkSemicolonAfterScope
1 call to UselessSemicolonSniff::checkSemicolonAfterScope()
- 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 96
Class
Namespace
SlevomatCodingStandard\Sniffs\PHPCode
private function checkSemicolonAfterScope(File $phpcsFile, int $semicolonPointer) : void {
$tokens = $phpcsFile->getTokens();
$previousPointer = TokenHelper::findPreviousEffective($phpcsFile, $semicolonPointer - 1);
if ($tokens[$previousPointer]['code'] !== T_CLOSE_CURLY_BRACKET) {
return;
}
if (!array_key_exists('scope_condition', $tokens[$previousPointer])) {
return;
}
$scopeOpenerPointer = $tokens[$previousPointer]['scope_condition'];
if (in_array($tokens[$scopeOpenerPointer]['code'], [
T_CLOSURE,
T_FN,
T_ANON_CLASS,
T_MATCH,
], true)) {
return;
}
$fix = $phpcsFile->addFixableError('Useless semicolon.', $semicolonPointer, self::CODE_USELESS_SEMICOLON);
if (!$fix) {
return;
}
$this->removeUselessSemicolon($phpcsFile, $semicolonPointer);
}