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

Breadcrumb

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

function DisallowNonCapturingCatchSniff::process

* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *

Parameters

int $catchPointer:

Overrides Sniff::process

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Exceptions/DisallowNonCapturingCatchSniff.php, line 30

Class

DisallowNonCapturingCatchSniff

Namespace

SlevomatCodingStandard\Sniffs\Exceptions

Code

public function process(File $phpcsFile, $catchPointer) : void {
    $tokens = $phpcsFile->getTokens();
    $variablePointer = TokenHelper::findNext($phpcsFile, T_VARIABLE, $tokens[$catchPointer]['parenthesis_opener'], $tokens[$catchPointer]['parenthesis_closer']);
    if ($variablePointer === null) {
        $phpcsFile->addError('Use of non-capturing catch is disallowed.', $catchPointer, self::CODE_DISALLOWED_NON_CAPTURING_CATCH);
    }
}
RSS feed
Powered by Drupal