You are here

protected function VariableAnalysisSniff::checkForSymbolicObjectProperty in Coder 8.2

Check if the variable is an object property.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile:

int $stackPtr:

string $varName:

string $currScope:

Return value

bool

1 call to VariableAnalysisSniff::checkForSymbolicObjectProperty()
VariableAnalysisSniff::processVariable in coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
Called to process normal member vars.

File

coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php, line 1905

Class

VariableAnalysisSniff
Checks the for undefined function variables.

Namespace

DrupalPractice\Sniffs\CodeAnalysis

Code

protected function checkForSymbolicObjectProperty(File $phpcsFile, $stackPtr, $varName, $currScope) {
  $tokens = $phpcsFile
    ->getTokens();
  $token = $tokens[$stackPtr];

  // Are we a symbolic object property/function derefeference?
  // Search backwards for first token that isn't whitespace, is it a "->" operator?
  $objectOperatorPtr = $phpcsFile
    ->findPrevious(T_WHITESPACE, $stackPtr - 1, null, true, null, true);
  if ($objectOperatorPtr === false || $tokens[$objectOperatorPtr]['code'] !== T_OBJECT_OPERATOR) {
    return false;
  }
  $this
    ->markVariableReadAndWarnIfUndefined($phpcsFile, $varName, $stackPtr, $currScope);
  return true;
}