Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Aug 22, 2024
1 parent 7968c05 commit 9708f61
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rules/Php84/Rector/Param/ExplicitNullableParamTypeRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ public function refactor(Node $node): ?Param
return null;
}

$newNodeType = TypeCombinator::addNull($nodeType);
$paramType = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($newNodeType, TypeKind::PARAM);

// ensure it process valid Node, otherwise, just return null
if ($paramType === null) {
return null;
}

// re-use existing node instead of reprint Node that may cause unnecessary FQCN
if ($node->type instanceof UnionType) {
$node->type->types[] = new ConstFetch(new Name('null'));
} else {
Expand Down

0 comments on commit 9708f61

Please sign in to comment.