You are here

protected function VariableAnalysisSniff::checkForSuperGlobal in Coder 8.2

Checks if the variable is a PHP super global.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile:

int $stackPtr:

string $varName:

string $currScope:

Return value

bool

2 calls to VariableAnalysisSniff::checkForSuperGlobal()
VariableAnalysisSniff::processVariable in coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
Called to process normal member vars.
VariableAnalysisSniff::processVariableInString in coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
Called to process variables found in double quoted strings.

File

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

Class

VariableAnalysisSniff
Checks the for undefined function variables.

Namespace

DrupalPractice\Sniffs\CodeAnalysis

Code

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

  // Are we a superglobal variable?
  if (in_array($varName, array(
    'GLOBALS',
    '_SERVER',
    '_GET',
    '_POST',
    '_FILES',
    '_COOKIE',
    '_SESSION',
    '_REQUEST',
    '_ENV',
    'argv',
    'argc',
  )) === true) {
    return true;
  }
  return false;
}