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

Breadcrumb

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

function AssignmentInConditionSniff::process

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

* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

Parameters

int $conditionStartPointer:

Overrides Sniff::process

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/ControlStructures/AssignmentInConditionSniff.php, line 41

Class

AssignmentInConditionSniff

Namespace

SlevomatCodingStandard\Sniffs\ControlStructures

Code

public function process(File $phpcsFile, $conditionStartPointer) : void {
    $tokens = $phpcsFile->getTokens();
    $token = $tokens[$conditionStartPointer];
    if ($token['code'] === T_DO) {
        $whilePointer = TokenHelper::findNext($phpcsFile, T_WHILE, $token['scope_closer'] + 1);
        $whileToken = $tokens[$whilePointer];
        $parenthesisOpener = $whileToken['parenthesis_opener'];
        $parenthesisCloser = $whileToken['parenthesis_closer'];
        $type = 'do-while';
    }
    else {
        $parenthesisOpener = $token['parenthesis_opener'];
        $parenthesisCloser = $token['parenthesis_closer'];
        $type = $token['code'] === T_IF ? 'if' : 'elseif';
    }
    if ($parenthesisOpener === null || $parenthesisCloser === null) {
        return;
    }
    $this->processCondition($phpcsFile, $parenthesisOpener, $parenthesisCloser, $type);
}

API Navigation

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