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
Namespace
SlevomatCodingStandard\Sniffs\ExceptionsCode
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;
}