Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FunctionCommentSniff.php

function FunctionCommentSniff::checkInheritdoc

Determines whether the whole comment is an inheritdoc comment.

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 in the stack where the comment started.:

Return value

boolean TRUE if the docblock contains only (case-insensitive).

3 calls to FunctionCommentSniff::checkInheritdoc()
FunctionCommentSniff::processParams in vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php
Process the function parameter comments.
FunctionCommentSniff::processReturn in vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php
Process the return comment of this function comment.
FunctionCommentSniff::processThrows in vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php
Process any throw tags that this function comment has.

File

vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php, line 774

Class

FunctionCommentSniff

Namespace

PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting

Code

protected function checkInheritdoc(File $phpcsFile, $stackPtr, $commentStart) {
    $tokens = $phpcsFile->getTokens();
    $allowedTokens = [
        T_DOC_COMMENT_OPEN_TAG,
        T_DOC_COMMENT_WHITESPACE,
        T_DOC_COMMENT_STAR,
    ];
    for ($i = $commentStart; $i <= $tokens[$commentStart]['comment_closer']; $i++) {
        if (in_array($tokens[$i]['code'], $allowedTokens) === false) {
            $trimmedContent = strtolower(trim($tokens[$i]['content']));
            if ($trimmedContent === '{@inheritdoc}') {
                return true;
            }
            else {
                return false;
            }
        }
    }
    return false;
}
RSS feed
Powered by Drupal