Skip to content

Commit

Permalink
[TypeDeclaration] Skip @inheritdoc on PropertyTypeDeclaration (#1752)
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypkhantc committed Feb 15, 2022
1 parent c4b25ec commit 7d8444e
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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';
}
?>
Original file line number Diff line number Diff line change
@@ -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';
}
?>
Original file line number Diff line number Diff line change
@@ -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';
}
?>
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public function refactor(Node $node): ?Node

$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);

if ($phpDocInfo->hasInheritDoc() && ! $node->isPrivate()) {
return null;
}

if ($this->isVarDocAlreadySet($phpDocInfo)) {
return null;
}
Expand Down

0 comments on commit 7d8444e

Please sign in to comment.