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

Breadcrumb

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

function UseSpacingSniff::process

* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

Parameters

int $openTagPointer:

Overrides Sniff::process

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Namespaces/UseSpacingSniff.php, line 54

Class

UseSpacingSniff

Namespace

SlevomatCodingStandard\Sniffs\Namespaces

Code

public function process(File $phpcsFile, $openTagPointer) : void {
    $this->linesCountBeforeFirstUse = SniffSettingsHelper::normalizeInteger($this->linesCountBeforeFirstUse);
    $this->linesCountBetweenUseTypes = SniffSettingsHelper::normalizeInteger($this->linesCountBetweenUseTypes);
    $this->linesCountAfterLastUse = SniffSettingsHelper::normalizeInteger($this->linesCountAfterLastUse);
    if (TokenHelper::findPrevious($phpcsFile, T_OPEN_TAG, $openTagPointer - 1) !== null) {
        return;
    }
    $fileUseStatements = UseStatementHelper::getFileUseStatements($phpcsFile);
    if (count($fileUseStatements) === 0) {
        return;
    }
    foreach ($fileUseStatements as $useStatementsByName) {
        $useStatements = array_values($useStatementsByName);
        $this->checkLinesBeforeFirstUse($phpcsFile, $useStatements[0]);
        $this->checkLinesAfterLastUse($phpcsFile, $useStatements[count($useStatements) - 1]);
        $this->checkLinesBetweenSameTypesOfUse($phpcsFile, $useStatements);
        $this->checkLinesBetweenDifferentTypesOfUse($phpcsFile, $useStatements);
    }
}
RSS feed
Powered by Drupal