public function ExpectedExceptionSniff::process in Coder 8.2
Same name and namespace in other branches
- 8.3 coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php \DrupalPractice\Sniffs\Commenting\ExpectedExceptionSniff::process()
- 8.3.x coder_sniffer/DrupalPractice/Sniffs/Commenting/ExpectedExceptionSniff.php \DrupalPractice\Sniffs\Commenting\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
File
- coder_sniffer/
DrupalPractice/ Sniffs/ Commenting/ ExpectedExceptionSniff.php, line 49
Class
- ExpectedExceptionSniff
- Checks that the PHPunit @expectedExcpetion 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,
]);
}
}