Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UselessSemicolonSniff.php

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

UselessSemicolonSniff

Namespace

SlevomatCodingStandard\Sniffs\PHP

Code

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);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal