class DisallowNonCapturingCatchSniff
Hierarchy
- class \SlevomatCodingStandard\Sniffs\Exceptions\DisallowNonCapturingCatchSniff implements \PHP_CodeSniffer\Sniffs\Sniff
Expanded class hierarchy of DisallowNonCapturingCatchSniff
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Exceptions/ DisallowNonCapturingCatchSniff.php, line 11
Namespace
SlevomatCodingStandard\Sniffs\ExceptionsView source
class DisallowNonCapturingCatchSniff implements Sniff {
public const CODE_DISALLOWED_NON_CAPTURING_CATCH = 'DisallowedNonCapturingCatch';
/**
* @return array<int, (int|string)>
*/
public function register() : array {
return [
T_CATCH,
];
}
/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint
* @param int $catchPointer
*/
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);
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
DisallowNonCapturingCatchSniff::CODE_DISALLOWED_NON_CAPTURING_CATCH | public | constant | ||
DisallowNonCapturingCatchSniff::process | public | function | * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint * |
Overrides Sniff::process |
DisallowNonCapturingCatchSniff::register | public | function | * | Overrides Sniff::register |