function 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
Overrides Sniff::process
File
-
vendor/
drupal/ coder/ 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');
}
}