opt
/
cpanel
/
ea-wappspector
/
vendor
/
slevomat
/
coding-standard
/
SlevomatCodingStandard
/
Sniffs
/
Numbers
➕ New
📤 Upload
✎ Editing:
DisallowNumericLiteralSeparatorSniff.php
← Back
<?php declare(strict_types = 1); namespace SlevomatCodingStandard\Sniffs\Numbers; use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use SlevomatCodingStandard\Helpers\FixerHelper; use function str_replace; use function strpos; use const T_DNUMBER; use const T_LNUMBER; class DisallowNumericLiteralSeparatorSniff implements Sniff { public const CODE_DISALLOWED_NUMERIC_LITERAL_SEPARATOR = 'DisallowedNumericLiteralSeparator'; /** * @return array<int, (int|string)> */ public function register(): array { return [ T_LNUMBER, T_DNUMBER, ]; } /** * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint * @param int $numberPointer */ 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(); FixerHelper::replace( $phpcsFile, $numberPointer, str_replace('_', '', $tokens[$numberPointer]['content']), ); $phpcsFile->fixer->endChangeset(); } }
💾 Save Changes
Cancel
📤 Upload File
×
Select File
Upload
Cancel
➕ Create New
×
Type
📄 File
📁 Folder
Name
Create
Cancel
✎ Rename Item
×
Current Name
New Name
Rename
Cancel
🔐 Change Permissions
×
Target File
Permission (e.g., 0755, 0644)
0755
0644
0777
Apply
Cancel