public function VariableAnalysisSniff::process in Coder 8.2
Processes this test, when one of its tokens is encountered.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
int $stackPtr The position of the current token: in the stack passed in $tokens.
Return value
void
File
- coder_sniffer/
DrupalPractice/ Sniffs/ CodeAnalysis/ VariableAnalysisSniff.php, line 620
Class
- VariableAnalysisSniff
- Checks the for undefined function variables.
Namespace
DrupalPractice\Sniffs\CodeAnalysisCode
public function process(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile
->getTokens();
$token = $tokens[$stackPtr];
// Debug code.
// if ($token['content'] == '$param') {
// echo "Found token on line {$token['line']}.\n" . print_r($token, true);
// }
// End: Debug code.
if ($this->currentFile !== $phpcsFile) {
$this->currentFile = $phpcsFile;
}
if ($token['code'] === T_VARIABLE) {
return $this
->processVariable($phpcsFile, $stackPtr);
}
if ($token['code'] === T_DOUBLE_QUOTED_STRING || $token['code'] === T_HEREDOC) {
return $this
->processVariableInString($phpcsFile, $stackPtr);
}
if ($token['code'] === T_STRING && $token['content'] === 'compact') {
return $this
->processCompact($phpcsFile, $stackPtr);
}
if ($token['code'] === T_CLOSE_CURLY_BRACKET && isset($token['scope_condition']) === true) {
return $this
->processScopeClose($phpcsFile, $token['scope_condition']);
}
}