function AbstractVariableSniff::processTokenOutsideScope
Processes the token outside the scope in the file.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where this: token was found.
int $stackPtr The position where the token was found.:
Return value
void|int Optionally returns a stack pointer. The sniff will not be called again on the current file until the returned stack pointer is reached. Return `$phpcsFile->numTokens` to skip the rest of the file.
Overrides AbstractScopeSniff::processTokenOutsideScope
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Sniffs/ AbstractVariableSniff.php, line 162
Class
Namespace
PHP_CodeSniffer\SniffsCode
protected final function processTokenOutsideScope(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
// These variables are not member vars.
if ($tokens[$stackPtr]['code'] === T_VARIABLE) {
return $this->processVariable($phpcsFile, $stackPtr);
}
else {
if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING || $tokens[$stackPtr]['code'] === T_HEREDOC) {
// Check to see if this string has a variable in it.
$pattern = '|(?<!\\\\)(?:\\\\{2})*\\${?[a-zA-Z0-9_]+}?|';
if (preg_match($pattern, $tokens[$stackPtr]['content']) !== 0) {
return $this->processVariableInString($phpcsFile, $stackPtr);
}
}
}
}