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

Breadcrumb

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

function DisallowNumericLiteralSeparatorSniff::process

* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

Parameters

int $numberPointer:

Overrides Sniff::process

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Numbers/DisallowNumericLiteralSeparatorSniff.php, line 32

Class

DisallowNumericLiteralSeparatorSniff

Namespace

SlevomatCodingStandard\Sniffs\Numbers

Code

public function process(File $phpcsFile, $numberPointer) : void {
    $tokens = $phpcsFile->getTokens();
    if (strpos($tokens[$numberPointer]['content'], '_') === false) {
        return;
    }
    $fix = $phpcsFile->addFixableError('Use of numeric literal separator is disallowed.', $numberPointer, self::CODE_DISALLOWED_NUMERIC_LITERAL_SEPARATOR);
    if (!$fix) {
        return;
    }
    $phpcsFile->fixer
        ->beginChangeset();
    $phpcsFile->fixer
        ->replaceToken($numberPointer, str_replace('_', '', $tokens[$numberPointer]['content']));
    $phpcsFile->fixer
        ->endChangeset();
}
RSS feed
Powered by Drupal