Skip to content

Commit

Permalink
[NodeTypeResolver] Move UnionType doc vs FullyQualified native type a…
Browse files Browse the repository at this point in the history
…s not equal to TypeComparator (#5793)
  • Loading branch information
samsonasik committed Apr 3, 2024
1 parent 52aa64f commit 8bce424
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions rules/DeadCode/PhpDoc/DeadParamTagValueNodeAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

namespace Rector\DeadCode\PhpDoc;

use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Param;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
Expand Down Expand Up @@ -46,10 +44,6 @@ public function isDead(ParamTagValueNode $paramTagValueNode, FunctionLike $funct
return false;
}

if ($paramTagValueNode->type instanceof UnionTypeNode && $param->type instanceof FullyQualified) {
return false;
}

if ($param->type instanceof Name && $this->nodeNameResolver->isName($param->type, 'object')) {
return $paramTagValueNode->type instanceof IdentifierTypeNode && (string) $paramTagValueNode->type === 'object';
}
Expand Down
6 changes: 6 additions & 0 deletions src/NodeTypeResolver/TypeComparator/TypeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace Rector\NodeTypeResolver\TypeComparator;

use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Reflection\ClassReflection;
Expand Down Expand Up @@ -81,6 +83,10 @@ public function arePhpParserAndPhpStanPhpDocTypesEqual(
TypeNode $phpStanDocTypeNode,
Node $node
): bool {
if ($phpStanDocTypeNode instanceof UnionTypeNode && $phpParserNode instanceof FullyQualified) {
return false;
}

$phpParserNodeType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($phpParserNode);
$phpStanDocType = $this->staticTypeMapper->mapPHPStanPhpDocTypeNodeToPHPStanType(
$phpStanDocTypeNode,
Expand Down

0 comments on commit 8bce424

Please sign in to comment.