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

Breadcrumb

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

function UnusedVariableSniff::isValueInForeachAndErrorIsIgnored

1 call to UnusedVariableSniff::isValueInForeachAndErrorIsIgnored()
UnusedVariableSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Variables/UnusedVariableSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Variables/UnusedVariableSniff.php, line 516

Class

UnusedVariableSniff

Namespace

SlevomatCodingStandard\Sniffs\Variables

Code

private function isValueInForeachAndErrorIsIgnored(File $phpcsFile, int $variablePointer) : bool {
    $tokens = $phpcsFile->getTokens();
    $parenthesisOwnerPointer = $this->findNestedParenthesisWithOwner($phpcsFile, $variablePointer);
    $isInForeach = $parenthesisOwnerPointer !== null && $tokens[$parenthesisOwnerPointer]['code'] === T_FOREACH;
    if (!$isInForeach) {
        return false;
    }
    $pointerAfterVariable = TokenHelper::findNextEffective($phpcsFile, $variablePointer + 1);
    if ($pointerAfterVariable !== null && $tokens[$pointerAfterVariable]['code'] === T_DOUBLE_ARROW) {
        return false;
    }
    return $this->ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach;
}

API Navigation

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