function EmptyCatchCommentSniff::process
Processes this test, when one of its tokens is encountered.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile All the tokens found in the document.:
int $stackPtr The position of the current token in the: stack passed in $tokens.
Return value
void
Overrides Sniff::process
File
-
vendor/
squizlabs/ php_codesniffer/ src/ Standards/ Squiz/ Sniffs/ Commenting/ EmptyCatchCommentSniff.php, line 40
Class
Namespace
PHP_CodeSniffer\Standards\Squiz\Sniffs\CommentingCode
public function process(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
$scopeStart = $tokens[$stackPtr]['scope_opener'];
$firstContent = $phpcsFile->findNext(T_WHITESPACE, $scopeStart + 1, $tokens[$stackPtr]['scope_closer'], true);
if ($firstContent === false) {
$error = 'Empty CATCH statement must have a comment to explain why the exception is not handled';
$phpcsFile->addError($error, $scopeStart, 'Missing');
}
}