Commit 92c3c777 authored by Sergii Bondarenko's avatar Sergii Bondarenko Committed by Klaus Purer
Browse files

fix(DocComment): Allow inheritDoc with a capital D in doc comments (#2939783 by BR0kEN, klausi)

parent 6e961348
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -221,7 +221,10 @@ class DocCommentSniff implements Sniff
        // Remove any trailing white spaces which are detected by other sniffs.
        $shortContent = trim($shortContent);

        if (preg_match('|\p{Lu}|u', $shortContent[0]) === 0 && $shortContent !== '{@inheritdoc}'
        if (preg_match('|\p{Lu}|u', $shortContent[0]) === 0
            // Allow both variants of inheritdoc comments.
            && $shortContent !== '{@inheritdoc}'
            && $shortContent !== '{@inheritDoc}'
            // Ignore Features module export files that just use the file name as
            // comment.
            && $shortContent !== basename($phpcsFile->getFilename())
@@ -240,7 +243,10 @@ class DocCommentSniff implements Sniff
        }

        $lastChar = substr($shortContent, -1);
        if (in_array($lastChar, ['.', '!', '?', ')']) === false && $shortContent !== '{@inheritdoc}'
        if (in_array($lastChar, ['.', '!', '?', ')']) === false
            // Allow both variants of inheritdoc comments.
            && $shortContent !== '{@inheritdoc}'
            && $shortContent !== '{@inheritDoc}'
            // Ignore Features module export files that just use the file name as
            // comment.
            && $shortContent !== basename($phpcsFile->getFilename())
+4 −1
Original line number Diff line number Diff line
@@ -86,8 +86,11 @@ class VariableCommentSniff extends AbstractVariableSniff

        $commentStart = $tokens[$commentEnd]['comment_opener'];

        // Ignore variable comments that use inheritdoc, allow both variants.
        $commentContent = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart));
        if (strpos($commentContent, '{@inheritdoc}') !== false) {
        if (strpos($commentContent, '{@inheritdoc}') !== false
            || strpos($commentContent, '{@inheritDoc}') !== false
        ) {
            return;
        }

+10 −0
Original line number Diff line number Diff line
@@ -616,6 +616,11 @@ class Bar {
   */
  protected $modules = ['node', 'user'];

  /**
   * {@inheritDoc}
   */
  protected $allowedModules = ['node', 'user'];

  /**
   * Enter description here ...
   */
@@ -1098,6 +1103,11 @@ class Foo implements FooInterface {
    throw new Exception();
  }

  /**
   * {@inheritDoc}
   */
  public function test8() {}

}

t('Some long mulit-line