function BrowserSpecificStylesSniff::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/ MySource/ Sniffs/ CSS/ BrowserSpecificStylesSniff.php, line 66
Class
Namespace
PHP_CodeSniffer\Standards\MySource\Sniffs\CSSCode
public function process(File $phpcsFile, $stackPtr) {
// Ignore files with browser-specific suffixes.
$filename = $phpcsFile->getFilename();
$breakChar = strrpos($filename, '_');
if ($breakChar !== false && substr($filename, -4) === '.css') {
$specific = substr($filename, $breakChar + 1, -4);
if (isset($this->specificStylesheets[$specific]) === true) {
return;
}
}
$tokens = $phpcsFile->getTokens();
$content = $tokens[$stackPtr]['content'];
if ($content[0] === '-') {
$error = 'Browser-specific styles are not allowed';
$phpcsFile->addError($error, $stackPtr, 'ForbiddenStyle');
}
}