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

Breadcrumb

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

function EmptyStyleDefinitionSniff::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/EmptyStyleDefinitionSniff.php, line 50

Class

EmptyStyleDefinitionSniff

Namespace

PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS

Code

public function process(File $phpcsFile, $stackPtr) {
    $tokens = $phpcsFile->getTokens();
    $ignore = Tokens::$emptyTokens;
    $ignore[] = T_COLON;
    $next = $phpcsFile->findNext($ignore, $stackPtr + 1, null, true);
    if ($next === false || $tokens[$next]['code'] === T_SEMICOLON || $tokens[$next]['line'] !== $tokens[$stackPtr]['line']) {
        $error = 'Style definition is empty';
        $phpcsFile->addError($error, $stackPtr, 'Found');
    }
}
RSS feed
Powered by Drupal