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

Breadcrumb

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

function ColourDefinitionSniff::process

Same name in this branch
  1. 11.1.x vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php \PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS\ColourDefinitionSniff::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/drupal/coder/coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php, line 56

Class

ColourDefinitionSniff
\Drupal\Sniffs\CSS\ColourDefinitionSniff.

Namespace

Drupal\Sniffs\CSS

Code

public function process(File $phpcsFile, $stackPtr) {
    $tokens = $phpcsFile->getTokens();
    $color = $tokens[$stackPtr]['content'];
    $expected = strtolower($color);
    if ($color !== $expected) {
        $error = 'CSS colors must be defined in lowercase; expected %s but found %s';
        $data = [
            $expected,
            $color,
        ];
        $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotLower', $data);
        if ($fix === true) {
            $phpcsFile->fixer
                ->replaceToken($stackPtr, $expected);
        }
    }
}
RSS feed
Powered by Drupal