diff --git a/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php b/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php index 748ce62cd3f..62a14d20aa2 100644 --- a/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php +++ b/packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php @@ -12,6 +12,7 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode; +use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode; use PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode; use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode; @@ -443,7 +444,21 @@ final class PhpDocInfo public function hasInheritDoc(): bool { - return $this->hasByNames(['inheritdoc', 'inheritDoc']); + if ($this->hasByNames(['inheritdoc', 'inheritDoc'])) { + return true; + } + + foreach ($this->phpDocNode->children as $children) { + if (! $children instanceof PhpDocTextNode) { + continue; + } + + if (in_array($children->text, ['{@inheritdoc}', '{@inheritDoc}'], true)) { + return true; + } + } + + return false; } /** diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Fixture/skip_curly_inherit_doc.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Fixture/skip_curly_inherit_doc.php.inc new file mode 100644 index 00000000000..eba1e364e51 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Fixture/skip_curly_inherit_doc.php.inc @@ -0,0 +1,22 @@ + 'string', + 'b' => 1, + 'c' => 1.0 + ] + ]; + } +} diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Fixture/skip_inherit_doc.php.inc b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Fixture/skip_inherit_doc.php.inc index 10619695c5c..7f9412b63a4 100644 --- a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Fixture/skip_inherit_doc.php.inc +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Fixture/skip_inherit_doc.php.inc @@ -2,7 +2,9 @@ namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector\Fixture; -class SkipInheritDoc extends ParentClassWithDefinedReturnSecond +use Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source\ParentClassWithDefinedReturnSecond; + +class SkipCurlyInheritDoc extends ParentClassWithDefinedReturnSecond { /** * @inheritdoc @@ -18,15 +20,3 @@ class SkipInheritDoc extends ParentClassWithDefinedReturnSecond ]; } } - - -abstract class ParentClassWithDefinedReturnSecond -{ - /** - * @return mixed[] - */ - public function getData() - { - return ['...']; - } -} diff --git a/rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Source/ParentClassWithDefinedReturnSecond.php b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Source/ParentClassWithDefinedReturnSecond.php new file mode 100644 index 00000000000..0818e03fbe5 --- /dev/null +++ b/rules-tests/TypeDeclaration/Rector/ClassMethod/AddArrayReturnDocTypeRector/Source/ParentClassWithDefinedReturnSecond.php @@ -0,0 +1,16 @@ +