Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NamedColoursSniff.php

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

NamedColoursSniff

Namespace

PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS

Code

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');
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal