mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-27 05:03:31 +00:00
[TypeDeclaration] Skip curly {@inheritdoc} on AddArrayReturnDocTypeRector (#2359)
This commit is contained in:
parent
4c53b206a4
commit
9c6b3d708c
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector\Fixture;
|
||||
|
||||
use Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source\ParentClassWithDefinedReturnSecond;
|
||||
|
||||
class SkipCurlyInheritDoc extends ParentClassWithDefinedReturnSecond
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'a' => 'string',
|
||||
'b' => 1,
|
||||
'c' => 1.0
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
|
@ -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 ['...'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector\Source;
|
||||
|
||||
abstract class ParentClassWithDefinedReturnSecond
|
||||
{
|
||||
/**
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
return ['...'];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user