function ExpectedExceptionSniff::process
Processes this test, when one of its tokens is encountered.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
int $stackPtr The position of the current token: in the stack passed in $tokens.
Return value
void
Overrides Sniff::process
File
-
vendor/
drupal/ coder/ coder_sniffer/ DrupalPractice/ Sniffs/ Commenting/ ExpectedExceptionSniff.php, line 49
Class
- ExpectedExceptionSniff
- Checks that the PHPunit @expectedException tags are not used.
Namespace
DrupalPractice\Sniffs\CommentingCode
public function process(File $phpcsFile, $stackPtr) {
$tokens = $phpcsFile->getTokens();
$content = $tokens[$stackPtr]['content'];
if ($content === '@expectedException' || $content === '@expectedExceptionCode' || $content === '@expectedExceptionMessage' || $content === '@expectedExceptionMessageRegExp') {
$warning = '%s tags should not be used, use $this->setExpectedException() or $this->expectException() instead';
$phpcsFile->addWarning($warning, $stackPtr, 'TagFound', [
$content,
]);
}
}