function VariableAnalysisSniff::markVariableReadAndWarnIfUndefined in Coder 8.2
Marks a variable as read and throws a PHPCS warning if it is undefined.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile:
string $varName:
int $stackPtr:
string $currScope:
Return value
bool
4 calls to VariableAnalysisSniff::markVariableReadAndWarnIfUndefined()
- VariableAnalysisSniff::checkForSymbolicObjectProperty in coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php - Check if the variable is an object property.
- VariableAnalysisSniff::processCompactArguments in coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php - Check variables in a compact() call.
- 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 912
Class
- VariableAnalysisSniff
- Checks the for undefined function variables.
Namespace
DrupalPractice\Sniffs\CodeAnalysisCode
function markVariableReadAndWarnIfUndefined(File $phpcsFile, $varName, $stackPtr, $currScope) {
$this
->markVariableRead($varName, $stackPtr, $currScope);
if ($this
->isVariableUndefined($varName, $stackPtr, $currScope) === true) {
// We haven't been defined by this point.
$phpcsFile
->addWarning("Variable %s is undefined.", $stackPtr, 'UndefinedVariable', array(
"\${$varName}",
));
}
return true;
}