Skip to content

Commit

Permalink
skip false positive chagne report on RemoveUselessParamTagRector (#3151)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Dec 4, 2022
1 parent efd09bb commit 3dea2bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 8 additions & 2 deletions rules/DeadCode/PhpDoc/TagRemover/ParamTagRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ public function __construct(
) {
}

public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike): void
public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike): bool
{
$hasChanged = false;

$phpDocNodeTraverser = new PhpDocNodeTraverser();
$phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (Node $docNode) use (
$functionLike,
$phpDocInfo
$phpDocInfo,
&$hasChanged
): ?int {
if (! $docNode instanceof PhpDocTagNode) {
return null;
Expand All @@ -44,7 +47,10 @@ public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $f
}

$phpDocInfo->markAsChanged();
$hasChanged = true;
return PhpDocNodeTraverser::NODE_REMOVE;
});

return $hasChanged;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ public function refactor(Node $node): ?Node
return null;
}

$this->paramTagRemover->removeParamTagsIfUseless($phpDocInfo, $node);

if ($phpDocInfo->hasChanged()) {
$hasChanged = $this->paramTagRemover->removeParamTagsIfUseless($phpDocInfo, $node);
if ($hasChanged) {
return $node;
}

Expand Down

0 comments on commit 3dea2bd

Please sign in to comment.