public function FormStateInputSniff::process in Coder 8.2
Same name and namespace in other branches
- 8.3 coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php \DrupalPractice\Sniffs\General\FormStateInputSniff::process()
- 8.3.x coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php \DrupalPractice\Sniffs\General\FormStateInputSniff::process()
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 function: name in the stack.
Return value
void
File
- coder_sniffer/
DrupalPractice/ Sniffs/ General/ FormStateInputSniff.php, line 48
Class
- FormStateInputSniff
- Throws a message whenever $form_state['input'] is used. $form_state['values'] is preferred.
Namespace
DrupalPractice\Sniffs\GeneralCode
public function process(File $phpcsFile, $stackPtr) {
if ($phpcsFile
->getTokensAsString($stackPtr, 4) === '$form_state[\'input\']' || $phpcsFile
->getTokensAsString($stackPtr, 4) === '$form_state["input"]') {
$warning = 'Do not use the raw $form_state[\'input\'], use $form_state[\'values\'] instead where possible';
$phpcsFile
->addWarning($warning, $stackPtr, 'Input');
}
}