function VariableAnalysisSniff::getVariableInfo in Coder 8.2
Get variable information for a given variable name.
Parameters
string $varName: Name of the variable.
int $currScope: Token stack pointer of the current scope.
bool $autoCreate: TRUE if the variable should be auto created.
Return value
VariableInfo|null Information about the variable.
10 calls to VariableAnalysisSniff::getVariableInfo()
- VariableAnalysisSniff::checkForAssignment in coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php - Checks if the variable is being assigned to.
- 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::checkForGlobalDeclaration in coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php - Check if this variable is declared globally.
File
- coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php, line 731
Class
- VariableAnalysisSniff
- Checks the for undefined function variables.
Namespace
DrupalPractice\Sniffs\CodeAnalysisCode
function getVariableInfo($varName, $currScope, $autoCreate = true) {
$scopeInfo = $this
->getScopeInfo($currScope, $autoCreate);
if (isset($scopeInfo->variables[$varName]) === false) {
if ($autoCreate === false) {
return null;
}
$scopeInfo->variables[$varName] = new VariableInfo($varName);
if (is_array($this->validUnusedVariableNames) === true && in_array($varName, $this->validUnusedVariableNames) === true) {
$scopeInfo->variables[$varName]->ignoreUnused = true;
}
}
return $scopeInfo->variables[$varName];
}