public function StrictSchemaDisabledSniff::processMemberVar in Coder 8.3
Same name and namespace in other branches
- 8.3.x coder_sniffer/DrupalPractice/Sniffs/Objects/StrictSchemaDisabledSniff.php \DrupalPractice\Sniffs\Objects\StrictSchemaDisabledSniff::processMemberVar()
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 current token: in the stack passed in $tokens.
Return value
void
File
- coder_sniffer/
DrupalPractice/ Sniffs/ Objects/ StrictSchemaDisabledSniff.php, line 40
Class
- StrictSchemaDisabledSniff
- Checks that $strictConfigSchema is not set to FALSE in test classes.
Namespace
DrupalPractice\Sniffs\ObjectsCode
public function processMemberVar(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile
->getTokens();
if ($tokens[$stackPtr]['content'] === static::STRICT_CONFIG_SCHEMA_NAME && $this
->isTestClass($phpcsFile, $stackPtr) === true) {
$find = [
T_FALSE,
T_TRUE,
T_NULL,
T_SEMICOLON,
];
$next = $phpcsFile
->findNext($find, $stackPtr + 1);
// If this variable is being set, the only allowed value is TRUE.
// Otherwise if FALSE or NULL, schema checking is disabled.
if ($tokens[$next]['code'] !== T_TRUE) {
$error = 'Do not disable strict config schema checking in tests. Instead ensure your module properly declares its schema for configurations.';
$data = [
$tokens[$stackPtr]['content'],
];
$phpcsFile
->addError($error, $stackPtr, 'StrictConfigSchema', $data);
}
}
//end if
}