*/ public function register(): array { return [ T_USE, ]; } /** * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint * @param int $usePointer */ public function process(File $phpcsFile, $usePointer): void { if (!UseStatementHelper::isImportUse($phpcsFile, $usePointer)) { return; } $tokens = $phpcsFile->getTokens(); /** @var int $nextTokenPointer */ $nextTokenPointer = TokenHelper::findNextEffective($phpcsFile, $usePointer + 1); if ( in_array($tokens[$nextTokenPointer]['code'], TokenHelper::ONLY_NAME_TOKEN_CODES, true) && ( $tokens[$nextTokenPointer]['content'] === 'function' || $tokens[$nextTokenPointer]['content'] === 'const' ) ) { /** @var int $nextTokenPointer */ $nextTokenPointer = TokenHelper::findNextEffective($phpcsFile, $nextTokenPointer + 1); } if (!NamespaceHelper::isFullyQualifiedPointer($phpcsFile, $nextTokenPointer)) { return; } $fix = $phpcsFile->addFixableError( 'Use statement cannot start with a backslash.', $nextTokenPointer, self::CODE_STARTS_WITH_BACKSLASH, ); if (!$fix) { return; } $phpcsFile->fixer->beginChangeset(); FixerHelper::replace( $phpcsFile, $nextTokenPointer, ltrim($tokens[$nextTokenPointer]['content'], '\\'), ); $phpcsFile->fixer->endChangeset(); } }