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

Breadcrumb

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

function NamespaceDeclarationSniff::checkDisallowedBracketedSyntax

1 call to NamespaceDeclarationSniff::checkDisallowedBracketedSyntax()
NamespaceDeclarationSniff::process in vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Namespaces/NamespaceDeclarationSniff.php
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Namespaces/NamespaceDeclarationSniff.php, line 123

Class

NamespaceDeclarationSniff

Namespace

SlevomatCodingStandard\Sniffs\Namespaces

Code

private function checkDisallowedBracketedSyntax(File $phpcsFile, int $namespacePointer) : void {
    $tokens = $phpcsFile->getTokens();
    if (!array_key_exists('scope_opener', $tokens[$namespacePointer])) {
        return;
    }
    $fix = $phpcsFile->addFixableError('Bracketed syntax for namespaces is disallowed.', $namespacePointer, self::CODE_DISALLOWED_BRACKETED_SYNTAX);
    if (!$fix) {
        return;
    }
    $phpcsFile->fixer
        ->beginChangeset();
    $phpcsFile->fixer
        ->replaceToken($tokens[$namespacePointer]['scope_opener'], ';');
    $phpcsFile->fixer
        ->replaceToken($tokens[$namespacePointer]['scope_closer'], '');
    $phpcsFile->fixer
        ->endChangeset();
}

API Navigation

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