function DisallowMultipleStyleDefinitionsSniff::process
Processes the tokens that this sniff is interested in.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file where the token was found.:
int $stackPtr The position in the stack where: the token was found.
Return value
void
Overrides Sniff::process
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Squiz/ Sniffs/ CSS/ DisallowMultipleStyleDefinitionsSniff.php, line 49
Class
Namespace
PHP_CodeSniffer\Standards\Squiz\Sniffs\CSSCode
public function process(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
$next = $phpcsFile->findNext(T_STYLE, $stackPtr + 1);
if ($next === false) {
return;
}
if ($tokens[$next]['content'] === 'progid') {
// Special case for IE filters.
return;
}
if ($tokens[$next]['line'] === $tokens[$stackPtr]['line']) {
$error = 'Each style definition must be on a line by itself';
$fix = $phpcsFile->addFixableError($error, $next, 'Found');
if ($fix === true) {
$phpcsFile->fixer
->addNewlineBefore($next);
}
}
}