@@ -113,13 +113,16 @@ public function refactor(Node $node): ?Node
113113
114114 private function updateDocblock (Variable $ variable , string $ variableName , string $ camelCaseName ): void
115115 {
116- $ parentClassMethodOrFunction = $ this ->betterNodeFinder ->findParentByTypes ($ variable , [ ClassMethod::class, Function_::class] );
116+ $ parentFunctionLike = $ this ->betterNodeFinder ->findParentType ($ variable , ClassMethod::class);
117117
118- if ($ parentClassMethodOrFunction === null ) {
119- return ;
118+ if ($ parentFunctionLike === null ) {
119+ $ parentFunctionLike = $ this ->betterNodeFinder ->findParentType ($ variable , Function_::class);
120+ if ($ parentFunctionLike === null ) {
121+ return ;
122+ }
120123 }
121124
122- $ docComment = $ parentClassMethodOrFunction ->getDocComment ();
125+ $ docComment = $ parentFunctionLike ->getDocComment ();
123126 if ($ docComment === null ) {
124127 return ;
125128 }
@@ -133,7 +136,7 @@ private function updateDocblock(Variable $variable, string $variableName, string
133136 return ;
134137 }
135138
136- $ phpDocInfo = $ this ->phpDocInfoFactory ->createFromNodeOrEmpty ($ parentClassMethodOrFunction );
139+ $ phpDocInfo = $ this ->phpDocInfoFactory ->createFromNodeOrEmpty ($ parentFunctionLike );
137140 $ paramTagValueNodes = $ phpDocInfo ->getParamTagValueNodes ();
138141
139142 foreach ($ paramTagValueNodes as $ paramTagValueNode ) {
@@ -143,6 +146,6 @@ private function updateDocblock(Variable $variable, string $variableName, string
143146 }
144147 }
145148
146- $ parentClassMethodOrFunction ->setDocComment (new Doc ($ phpDocInfo ->getPhpDocNode ()->__toString ()));
149+ $ parentFunctionLike ->setDocComment (new Doc ($ phpDocInfo ->getPhpDocNode ()->__toString ()));
147150 }
148151}
0 commit comments