[TypeDeclaration] Skip @inheritdoc on PropertyTypeDeclaration (#1752)

This commit is contained in:
oprypkhantc 2022-02-15 17:28:35 +02:00 committed by GitHub
parent c4b25ec066
commit 7d8444e81b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,24 @@
<?php
namespace Rector\Tests\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector\Fixture;
final class PrivateWithInheritDoc {
/**
* @inheritDoc
*/
private $property = 'test';
}
?>
-----
<?php
namespace Rector\Tests\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector\Fixture;
final class PrivateWithInheritDoc {
/**
* @inheritDoc
* @var string
*/
private $property = 'test';
}
?>

View File

@ -0,0 +1,14 @@
<?php
namespace Rector\Tests\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector\Fixture;
class SkipTypedInheritDocParent {
/** @var string */
public $property;
}
final class SkipTypedInheritDoc extends SkipTypedInheritDocParent {
/** @inheritDoc */
public $property = 'test';
}
?>

View File

@ -0,0 +1,13 @@
<?php
namespace Rector\Tests\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector\Fixture;
class SkipUntypedInheritDocParent {
public $property;
}
final class SkipUntypedInheritDoc extends SkipUntypedInheritDocParent {
/** @inheritDoc */
public $property = 'test';
}
?>

View File

@ -89,6 +89,10 @@ CODE_SAMPLE
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
if ($phpDocInfo->hasInheritDoc() && ! $node->isPrivate()) {
return null;
}
if ($this->isVarDocAlreadySet($phpDocInfo)) {
return null;
}