Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Sep 27, 2023
2 parents 9d139d2 + e1c2f5d commit 8e3dd0e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"phpunit/phpcov": "^8.2",
"phpunit/phpunit": "^9.1",
"predis/predis": "^1.1 || ^2.0",
"rector/rector": "0.18.3",
"rector/rector": "0.18.4",
"vimeo/psalm": "^5.0"
},
"suggest": {
Expand Down
13 changes: 13 additions & 0 deletions utils/Rector/RemoveVarTagFromClassConstantRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,23 @@
use PhpParser\Node;
use PhpParser\Node\Stmt\ClassConst;
use PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

final class RemoveVarTagFromClassConstantRector extends AbstractRector
{
private PhpDocInfoFactory $phpDocInfoFactory;
private DocBlockUpdater $docBlockUpdater;

public function __construct(PhpDocInfoFactory $phpDocInfoFactory, DocBlockUpdater $docBlockUpdater)
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->docBlockUpdater = $docBlockUpdater;
}

public function getRuleDefinition(): RuleDefinition
{
return new RuleDefinition('Remove @var tag from class constant', [
Expand Down Expand Up @@ -64,6 +75,8 @@ public function refactor(Node $node): ?Node

$phpDocInfo->removeByType(VarTagValueNode::class);

$this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);

return $node;
}
}

0 comments on commit 8e3dd0e

Please sign in to comment.