Skip to content

Commit 953f7d9

Browse files
committed
Skip for catch tokens.
1 parent dc1665b commit 953f7d9

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

PhpCollective/Sniffs/Commenting/DocBlockThrowsSniff.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ public function process(File $phpCsFile, $stackPointer): void
7777

7878
return;
7979
}
80+
if ($this->containsCatchToken($tokens, $tokens[$stackPointer]['scope_opener'], $tokens[$stackPointer]['scope_closer'])) {
81+
return;
82+
}
8083

8184
$this->compareExceptionsAndAnnotations($phpCsFile, $exceptions, $annotations, $docBlockEndIndex);
8285
}
@@ -469,6 +472,26 @@ protected function containsComplexThrowToken(array $tokens, int $scopeOpener, in
469472
return false;
470473
}
471474

475+
/**
476+
* @param array<int, array<string, mixed>> $tokens
477+
* @param int $scopeOpener
478+
* @param int $scopeCloser
479+
*
480+
* @return bool
481+
*/
482+
protected function containsCatchToken(array $tokens, int $scopeOpener, int $scopeCloser): bool
483+
{
484+
for ($i = $scopeOpener + 1; $i < $scopeCloser; $i++) {
485+
if ($tokens[$i]['code'] !== T_CATCH) {
486+
continue;
487+
}
488+
489+
return true;
490+
}
491+
492+
return false;
493+
}
494+
472495
/**
473496
* @param array<int, array<string, mixed>> $tokens
474497
* @param int $scopeOpener

0 commit comments

Comments
 (0)