public function ThemeSniff::process in Coder 8.2
Same name and namespace in other branches
- 8.3 coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php \DrupalPractice\Sniffs\FunctionCalls\ThemeSniff::process()
- 8.3.x coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php \DrupalPractice\Sniffs\FunctionCalls\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
- 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', array(
$themeName,
));
}