1212use PHPStan \Type \MixedType ;
1313use PHPStan \Type \UnionType ;
1414use Rector \BetterPhpDocParser \PhpDocInfo \PhpDocInfoFactory ;
15- use Rector \BetterPhpDocParser \PhpDocManipulator \PhpDocTypeChanger ;
1615use Rector \Rector \AbstractRector ;
17- use Rector \StaticTypeMapper \ StaticTypeMapper ;
16+ use Rector \TypeDeclarationDocblocks \ NodeDocblockTypeDecorator ;
1817use Rector \TypeDeclarationDocblocks \TagNodeAnalyzer \UsefulArrayTagNodeAnalyzer ;
1918use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
2019use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
@@ -26,9 +25,8 @@ final class DocblockGetterReturnArrayFromPropertyDocblockVarRector extends Abstr
2625{
2726 public function __construct (
2827 private readonly PhpDocInfoFactory $ phpDocInfoFactory ,
29- private readonly StaticTypeMapper $ staticTypeMapper ,
3028 private readonly UsefulArrayTagNodeAnalyzer $ usefulArrayTagNodeAnalyzer ,
31- private readonly PhpDocTypeChanger $ phpDocTypeChanger
29+ private readonly NodeDocblockTypeDecorator $ nodeDocblockTypeDecorator
3230 ) {
3331 }
3432
@@ -96,11 +94,6 @@ public function refactor(Node $node): ?Node
9694 return null ;
9795 }
9896
99- // // return tag is already given
100- // if ($phpDocInfo->getReturnTagValue() instanceof ReturnTagValueNode) {
101- // return null;
102- // }
103-
10497 $ propertyFetch = $ this ->matchReturnLocalPropertyFetch ($ node );
10598 if (! $ propertyFetch instanceof PropertyFetch) {
10699 return null ;
@@ -118,14 +111,13 @@ public function refactor(Node $node): ?Node
118111 return null ;
119112 }
120113
121- $ propertyFetchDocTypeNode = $ this ->staticTypeMapper ->mapPHPStanTypeToPHPStanPhpDocTypeNode ($ propertyFetchType );
122-
123- $ this ->phpDocTypeChanger ->changeReturnTypeNode ($ node , $ phpDocInfo , $ propertyFetchDocTypeNode );
124-
125- // $returnTagValueNode = new ReturnTagValueNode($propertyFetchDocTypeNode, '');
126- // $phpDocInfo->addTagValueNode($returnTagValueNode);
127- //
128- // $this->docBlockUpdater->updateRefactoredNodeWithPhpDocInfo($node);
114+ if (! $ this ->nodeDocblockTypeDecorator ->decorateGenericIterableReturnType (
115+ $ propertyFetchType ,
116+ $ phpDocInfo ,
117+ $ node
118+ )) {
119+ return null ;
120+ }
129121
130122 return $ node ;
131123 }
0 commit comments