You are here

function VariableAnalysisSniff::findContainingBrackets in Coder 8.2

Find the parenthesis if the pointer is in some.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile:

int $stackPtr:

Return value

int|false

8 calls to VariableAnalysisSniff::findContainingBrackets()
VariableAnalysisSniff::checkForCatchBlock in coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
Checks if we are in a catch() block.
VariableAnalysisSniff::checkForForeachLoopVar in coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
Check if this is a foreach loop variable.
VariableAnalysisSniff::checkForFunctionPrototype in coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
Checks the function prototype.
VariableAnalysisSniff::checkForListAssignment in coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
Check if this is a list language construct assignment.
VariableAnalysisSniff::findFunctionCall in coder_sniffer/DrupalPractice/Sniffs/CodeAnalysis/VariableAnalysisSniff.php
Checks if the given pointer is in a function call.

... See full list

File

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

Class

VariableAnalysisSniff
Checks the for undefined function variables.

Namespace

DrupalPractice\Sniffs\CodeAnalysis

Code

function findContainingBrackets(File $phpcsFile, $stackPtr) {
  $tokens = $phpcsFile
    ->getTokens();
  if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
    $openPtrs = array_keys($tokens[$stackPtr]['nested_parenthesis']);
    return end($openPtrs);
  }
  return false;
}