Skip to content

Commit 4b2af2f

Browse files
committed
Improved detection of {@inheritdoc}
1 parent daa7ae4 commit 4b2af2f

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

SlevomatCodingStandard/Helpers/DocCommentHelper.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use function in_array;
1313
use function preg_match;
1414
use function sprintf;
15+
use function stripos;
1516
use function strtolower;
1617
use function trim;
1718
use const T_ABSTRACT;
@@ -130,7 +131,7 @@ public static function hasInheritdocAnnotation(File $phpcsFile, int $pointer): b
130131
}
131132

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

tests/Sniffs/Commenting/data/uselessFunctionDocCommentSniffNoErrors.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,20 @@ public function __construct()
1111
/**
1212
* {@inheritdoc}
1313
*/
14-
public function hasInheritdocAnnotation()
14+
public function hasInheritDocAnnotation()
1515
{
1616

1717
}
1818

19+
/**
20+
* Description.
21+
*
22+
* {@inheritDoc}
23+
*/
24+
public function hasDescriptionAndInheritDocAnnotation()
25+
{
26+
}
27+
1928
/**
2029
* Description
2130
*/

tests/Sniffs/TypeHints/data/returnTypeHintNoErrors.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ private function hasInheritdocAnnotation()
2121
return true;
2222
}
2323

24+
/**
25+
* Description.
26+
*
27+
* {@inheritDoc}
28+
*/
29+
public function hasDescriptionAndInheritDocAnnotation()
30+
{
31+
}
32+
2433
/**
2534
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint
2635
*/

0 commit comments

Comments
 (0)