class FormStateInputSniff in Coder 8.3
Same name and namespace in other branches
- 8.2 coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php \DrupalPractice\Sniffs\General\FormStateInputSniff
- 8.3.x coder_sniffer/DrupalPractice/Sniffs/General/FormStateInputSniff.php \DrupalPractice\Sniffs\General\FormStateInputSniff
Throws a message whenever $form_state['input'] is used. $form_state['values'] is preferred.
@category PHP @package PHP_CodeSniffer @link http://pear.php.net/package/PHP_CodeSniffer
Hierarchy
- class \DrupalPractice\Sniffs\General\FormStateInputSniff implements \PHP_CodeSniffer\Sniffs\Sniff
Expanded class hierarchy of FormStateInputSniff
File
- coder_sniffer/
DrupalPractice/ Sniffs/ General/ FormStateInputSniff.php, line 23
Namespace
DrupalPractice\Sniffs\GeneralView source
class FormStateInputSniff implements Sniff {
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array<int|string>
*/
public function register() {
return [
T_VARIABLE,
];
}
//end register()
/**
* Processes this test, when one of its tokens is encountered.
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the function
* name in the stack.
*
* @return void
*/
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');
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormStateInputSniff:: |
public | function | Processes this test, when one of its tokens is encountered. | |
FormStateInputSniff:: |
public | function | Returns an array of tokens this test wants to listen for. |