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

Breadcrumb

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

function JumpStatementsSpacingSniff::isFirstInCaseOrDefault

1 call to JumpStatementsSpacingSniff::isFirstInCaseOrDefault()
JumpStatementsSpacingSniff::getLinesCountBeforeFirst in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/JumpStatementsSpacingSniff.php

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/JumpStatementsSpacingSniff.php, line 241

Class

JumpStatementsSpacingSniff

Namespace

SlevomatCodingStandard\Sniffs\ControlStructures

Code

private function isFirstInCaseOrDefault(File $phpcsFile, int $jumpStatementPointer) : bool {
    $tokens = $phpcsFile->getTokens();
    $previousPointer = TokenHelper::findPreviousEffective($phpcsFile, $jumpStatementPointer - 1);
    if ($tokens[$previousPointer]['code'] !== T_COLON) {
        return false;
    }
    $firstPointerOnLine = TokenHelper::findFirstNonWhitespaceOnLine($phpcsFile, $previousPointer);
    return in_array($tokens[$firstPointerOnLine]['code'], [
        T_CASE,
        T_DEFAULT,
    ], true);
}
RSS feed
Powered by Drupal