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

Breadcrumb

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

function InlineControlStructureSniff::process

Same name in this branch
  1. 11.1.x vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php \PHP_CodeSniffer\Standards\Generic\Sniffs\ControlStructures\InlineControlStructureSniff::process()

Processes this test, when one of its tokens is encountered.

Parameters

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

int $stackPtr The position of the current token in: the stack passed in $tokens.

Return value

void

Overrides InlineControlStructureSniff::process

File

vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/ControlStructures/InlineControlStructureSniff.php, line 40

Class

InlineControlStructureSniff
\Drupal\Sniffs\ControlStructures\InlineControlStructureSniff.

Namespace

Drupal\Sniffs\ControlStructures

Code

public function process(File $phpcsFile, $stackPtr) {
    $tokens = $phpcsFile->getTokens();
    // Check for the alternate syntax for control structures with colons (:).
    if (isset($tokens[$stackPtr]['parenthesis_closer']) === true) {
        $start = $tokens[$stackPtr]['parenthesis_closer'];
    }
    else {
        $start = $stackPtr;
    }
    $scopeOpener = $phpcsFile->findNext(T_WHITESPACE, $start + 1, null, true);
    if ($tokens[$scopeOpener]['code'] === T_COLON) {
        return;
    }
    parent::process($phpcsFile, $stackPtr);
}
RSS feed
Powered by Drupal