function FunctionCommentSniff::isInCodeExample
Determines if a comment line is part of an
/
example.
Parameters
\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:
int $stackPtr The position of the current token: in the stack passed in $tokens.
int $commentStart The position of the start of the comment: in the stack passed in $tokens.
Return value
boolean Returns true if the comment line is within a @code block, false otherwise.
1 call to FunctionCommentSniff::isInCodeExample()
- FunctionCommentSniff::processParams in vendor/
drupal/ coder/ coder_sniffer/ Drupal/ Sniffs/ Commenting/ FunctionCommentSniff.php - Process the function parameter comments.
File
-
vendor/
drupal/ coder/ coder_sniffer/ Drupal/ Sniffs/ Commenting/ FunctionCommentSniff.php, line 974
Class
- FunctionCommentSniff
- Parses and verifies the doc comments for functions. Largely copied from PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\FunctionCommentSniff.
Namespace
Drupal\Sniffs\CommentingCode
protected function isInCodeExample(File $phpcsFile, $stackPtr, $commentStart) {
$tokens = $phpcsFile->getTokens();
if (strpos($tokens[$stackPtr]['content'], '@code') !== false) {
return true;
}
$prevTag = $phpcsFile->findPrevious([
T_DOC_COMMENT_TAG,
], $stackPtr - 1, $commentStart);
if ($prevTag === false) {
return false;
}
if ($tokens[$prevTag]['content'] === '@code') {
return true;
}
return false;
}