Skip to content

Commit

Permalink
Improved detection of {@inheritdoc}
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Jul 25, 2023
1 parent daa7ae4 commit 4b2af2f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion SlevomatCodingStandard/Helpers/DocCommentHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use function in_array;
use function preg_match;
use function sprintf;
use function stripos;
use function strtolower;
use function trim;
use const T_ABSTRACT;
Expand Down Expand Up @@ -130,7 +131,7 @@ public static function hasInheritdocAnnotation(File $phpcsFile, int $pointer): b
}

foreach ($parsedDocComment->getNode()->children as $child) {
if ($child instanceof PhpDocTextNode && strtolower($child->text) === '{@inheritdoc}') {
if ($child instanceof PhpDocTextNode && stripos($child->text, '{@inheritdoc}') !== false) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@ public function __construct()
/**
* {@inheritdoc}
*/
public function hasInheritdocAnnotation()
public function hasInheritDocAnnotation()
{

}

/**
* Description.
*
* {@inheritDoc}
*/
public function hasDescriptionAndInheritDocAnnotation()
{
}

/**
* Description
*/
Expand Down
9 changes: 9 additions & 0 deletions tests/Sniffs/TypeHints/data/returnTypeHintNoErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ private function hasInheritdocAnnotation()
return true;
}

/**
* Description.
*
* {@inheritDoc}
*/
public function hasDescriptionAndInheritDocAnnotation()
{
}

/**
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint
*/
Expand Down

0 comments on commit 4b2af2f

Please sign in to comment.