From 9708f61a01bf0709ef1f3beb534876475f388b4b Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 22 Aug 2024 22:17:18 +0700 Subject: [PATCH] clean --- .../Rector/Param/ExplicitNullableParamTypeRector.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rules/Php84/Rector/Param/ExplicitNullableParamTypeRector.php b/rules/Php84/Rector/Param/ExplicitNullableParamTypeRector.php index 79950fcfe1..1479f5c043 100644 --- a/rules/Php84/Rector/Param/ExplicitNullableParamTypeRector.php +++ b/rules/Php84/Rector/Param/ExplicitNullableParamTypeRector.php @@ -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 {