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

Breadcrumb

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

function SwitchDeclarationSniff::findNextCase

Find the next CASE or DEFAULT statement from a point in the file.

Note that nested switches are ignored.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:

int $stackPtr The position to start looking at.:

int $end The position to stop looking at.:

Return value

int|false

2 calls to SwitchDeclarationSniff::findNextCase()
SwitchDeclarationSniff::findNestedTerminator in vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Returns the position of the nested terminating statement.
SwitchDeclarationSniff::process in vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php
Processes this test, when one of its tokens is encountered.

File

vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php, line 217

Class

SwitchDeclarationSniff

Namespace

PHP_CodeSniffer\Standards\PSR2\Sniffs\ControlStructures

Code

private function findNextCase($phpcsFile, $stackPtr, $end) {
    $tokens = $phpcsFile->getTokens();
    while (($stackPtr = $phpcsFile->findNext([
        T_CASE,
        T_DEFAULT,
        T_SWITCH,
    ], $stackPtr, $end)) !== false) {
        // Skip nested SWITCH statements; they are handled on their own.
        if ($tokens[$stackPtr]['code'] === T_SWITCH) {
            $stackPtr = $tokens[$stackPtr]['scope_closer'];
            continue;
        }
        break;
    }
    return $stackPtr;
}

API Navigation

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