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

Breadcrumb

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

function UnusedVariableSniff::isInheritedVariablePassedByReference

1 call to UnusedVariableSniff::isInheritedVariablePassedByReference()
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 577

Class

UnusedVariableSniff

Namespace

SlevomatCodingStandard\Sniffs\Variables

Code

private function isInheritedVariablePassedByReference(File $phpcsFile, int $functionPointer, string $variableName) : bool {
    $tokens = $phpcsFile->getTokens();
    $usePointer = TokenHelper::findNextEffective($phpcsFile, $tokens[$functionPointer]['parenthesis_closer'] + 1);
    if ($tokens[$usePointer]['code'] !== T_USE) {
        return false;
    }
    $useParenthesisOpener = TokenHelper::findNextEffective($phpcsFile, $usePointer + 1);
    for ($i = $useParenthesisOpener + 1; $i < $tokens[$useParenthesisOpener]['parenthesis_closer']; $i++) {
        if ($tokens[$i]['code'] !== T_VARIABLE) {
            continue;
        }
        if ($tokens[$i]['content'] !== $variableName) {
            continue;
        }
        $pointerBeforeInheritedVariable = TokenHelper::findPreviousEffective($phpcsFile, $i - 1);
        if ($tokens[$pointerBeforeInheritedVariable]['code'] === T_BITWISE_AND) {
            return true;
        }
    }
    return false;
}

API Navigation

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