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

Breadcrumb

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

function UnusedVariableSniff::isReference

1 call to UnusedVariableSniff::isReference()
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 604

Class

UnusedVariableSniff

Namespace

SlevomatCodingStandard\Sniffs\Variables

Code

private function isReference(File $phpcsFile, int $scopeOwnerPointer, int $variablePointer) : bool {
    $tokens = $phpcsFile->getTokens();
    $scopeOpenerPointer = $tokens[$scopeOwnerPointer]['code'] === T_OPEN_TAG ? $scopeOwnerPointer : $tokens[$scopeOwnerPointer]['scope_opener'];
    for ($i = $scopeOpenerPointer + 1; $i < $variablePointer; $i++) {
        if ($tokens[$i]['code'] !== T_VARIABLE) {
            continue;
        }
        if ($tokens[$i]['content'] !== $tokens[$variablePointer]['content']) {
            continue;
        }
        $assignmentPointer = TokenHelper::findNextEffective($phpcsFile, $i + 1);
        if ($tokens[$assignmentPointer]['code'] !== T_EQUAL) {
            continue;
        }
        $referencePointer = TokenHelper::findNextEffective($phpcsFile, $assignmentPointer + 1);
        if ($tokens[$referencePointer]['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