function NamedColoursSniff::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/ NamedColoursSniff.php, line 76
Class
Namespace
PHP_CodeSniffer\Standards\Squiz\Sniffs\CSSCode
public function process(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
if ($tokens[$stackPtr - 1]['code'] === T_HASH || $tokens[$stackPtr - 1]['code'] === T_STRING_CONCAT) {
// Class name.
return;
}
if (isset($this->colourNames[strtolower($tokens[$stackPtr]['content'])]) === true) {
$error = 'Named colours are forbidden; use hex, rgb, or rgba values instead';
$phpcsFile->addError($error, $stackPtr, 'Forbidden');
}
}