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

Breadcrumb

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

function ReferenceThrowableOnlySniff::searchForThrowableInNextCatches

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

File

vendor/slevomat/coding-standard/SlevomatCodingStandard/Sniffs/Exceptions/ReferenceThrowableOnlySniff.php, line 117

Class

ReferenceThrowableOnlySniff

Namespace

SlevomatCodingStandard\Sniffs\Exceptions

Code

private function searchForThrowableInNextCatches(File $phpcsFile, int $catchPointer) : bool {
    $tokens = $phpcsFile->getTokens();
    $nextCatchPointer = TokenHelper::findNextEffective($phpcsFile, $tokens[$catchPointer]['scope_closer'] + 1);
    while ($nextCatchPointer !== null) {
        $nextCatchToken = $tokens[$nextCatchPointer];
        if ($nextCatchToken['code'] !== T_CATCH) {
            break;
        }
        $caughtTypes = CatchHelper::findCaughtTypesInCatch($phpcsFile, $nextCatchToken);
        if (in_array('\\Throwable', $caughtTypes, true)) {
            return true;
        }
        $nextCatchPointer = TokenHelper::findNextEffective($phpcsFile, $nextCatchToken['scope_closer'] + 1);
    }
    return false;
}

API Navigation

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