Skip to content

Commit

Permalink
Updated Rector to commit 8f59d4e23ed974bf9eba52a075ef4d1e2604c80d
Browse files Browse the repository at this point in the history
rectorphp/rector-src@8f59d4e [Php80] Skip remove non-mixed type doc on MixedTypeRector (#5874)
  • Loading branch information
TomasVotruba committed May 14, 2024
1 parent faba2d1 commit 4bcc8bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions rules/DeadCode/PhpDoc/TagRemover/ParamTagRemover.php
Expand Up @@ -3,6 +3,7 @@
declare (strict_types=1);
namespace Rector\DeadCode\PhpDoc\TagRemover;

use PHPStan\Type\Type;
use PhpParser\Node\FunctionLike;
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
Expand All @@ -28,11 +29,11 @@ public function __construct(DeadParamTagValueNodeAnalyzer $deadParamTagValueNode
$this->deadParamTagValueNodeAnalyzer = $deadParamTagValueNodeAnalyzer;
$this->docBlockUpdater = $docBlockUpdater;
}
public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike) : bool
public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $functionLike, ?Type $type = null) : bool
{
$hasChanged = \false;
$phpDocNodeTraverser = new PhpDocNodeTraverser();
$phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (Node $docNode) use($functionLike, &$hasChanged) : ?int {
$phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function (Node $docNode) use($functionLike, &$hasChanged, $type, $phpDocInfo) : ?int {
if (!$docNode instanceof PhpDocTagNode) {
return null;
}
Expand All @@ -43,6 +44,14 @@ public function removeParamTagsIfUseless(PhpDocInfo $phpDocInfo, FunctionLike $f
if ($docNode->name !== '@param') {
return null;
}
$paramType = $phpDocInfo->getParamType($docNode->value->parameterName);
if ($type instanceof Type) {
if ($type->equals($paramType)) {
$hasChanged = \true;
return PhpDocNodeTraverser::NODE_REMOVE;
}
return null;
}
if (!$this->deadParamTagValueNodeAnalyzer->isDead($docNode->value, $functionLike)) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion rules/Php80/Rector/FunctionLike/MixedTypeRector.php
Expand Up @@ -100,7 +100,7 @@ public function refactor(Node $node) : ?Node
$this->hasChanged = \false;
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
$this->refactorParamTypes($node, $phpDocInfo);
$hasChanged = $this->paramTagRemover->removeParamTagsIfUseless($phpDocInfo, $node);
$hasChanged = $this->paramTagRemover->removeParamTagsIfUseless($phpDocInfo, $node, new MixedType());
if ($this->hasChanged) {
return $node;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '035e7bdb76a5496c65b1c112933e4afe06ddc6f8';
public const PACKAGE_VERSION = '8f59d4e23ed974bf9eba52a075ef4d1e2604c80d';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-05-13 19:19:41';
public const RELEASE_DATE = '2024-05-14 15:26:48';
/**
* @var int
*/
Expand Down

0 comments on commit 4bcc8bb

Please sign in to comment.