function ThemeSniff::process
Processes this function call.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
int $stackPtr The position of the function call in: the stack.
Return value
void
Overrides FunctionCall::process
File
-
vendor/
drupal/ coder/ coder_sniffer/ DrupalPractice/ Sniffs/ FunctionCalls/ ThemeSniff.php, line 49
Class
- ThemeSniff
- \DrupalPractice\Sniffs\FunctionCalls\Checks that theme functions are not directly called.
Namespace
DrupalPractice\Sniffs\FunctionCallsCode
public function process(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
$functionName = $tokens[$stackPtr]['content'];
if (strpos($functionName, 'theme_') !== 0 || in_array($functionName, $this->reservedFunctions) === true || $this->isFunctionCall($phpcsFile, $stackPtr) === false) {
return;
}
$themeName = substr($functionName, 6);
$warning = "Do not call theme functions directly, use theme('%s', ...) instead";
$phpcsFile->addWarning($warning, $stackPtr, 'ThemeFunctionDirect', [
$themeName,
]);
}