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

Breadcrumb

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

function DisallowMultipleStyleDefinitionsSniff::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/DisallowMultipleStyleDefinitionsSniff.php, line 49

Class

DisallowMultipleStyleDefinitionsSniff

Namespace

PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS

Code

public function process(File $phpcsFile, $stackPtr) {
    $tokens = $phpcsFile->getTokens();
    $next = $phpcsFile->findNext(T_STYLE, $stackPtr + 1);
    if ($next === false) {
        return;
    }
    if ($tokens[$next]['content'] === 'progid') {
        // Special case for IE filters.
        return;
    }
    if ($tokens[$next]['line'] === $tokens[$stackPtr]['line']) {
        $error = 'Each style definition must be on a line by itself';
        $fix = $phpcsFile->addFixableError($error, $next, 'Found');
        if ($fix === true) {
            $phpcsFile->fixer
                ->addNewlineBefore($next);
        }
    }
}

API Navigation

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