@@ -109,6 +109,7 @@ public function refactor(Node $node): ?Node
109109 $ hasChanged = \false;
110110 $ extractValues = [];
111111 foreach ($ node ->stmts as $ key => $ stmt ) {
112+ $ hasChangedStmt = \false;
112113 if ($ stmt instanceof Expression && $ stmt ->expr instanceof FuncCall && $ this ->isName ($ stmt ->expr , 'extract ' ) && !$ stmt ->expr ->isFirstClassCallable ()) {
113114 $ appendExtractValues = $ this ->valueResolver ->getValue ($ stmt ->expr ->getArgs ()[0 ]->value );
114115 if (!is_array ($ appendExtractValues )) {
@@ -131,31 +132,37 @@ public function refactor(Node $node): ?Node
131132 continue ;
132133 }
133134 $ phpDocInfo = $ this ->phpDocInfoFactory ->createFromNodeOrEmpty ($ stmt );
134- $ varTagValueNode = $ phpDocInfo ->getVarTagValueNode ();
135- if (!$ varTagValueNode instanceof VarTagValueNode) {
136- continue ;
137- }
138- if ($ this ->isObjectShapePseudoType ($ varTagValueNode )) {
139- continue ;
140- }
141- $ variableName = ltrim ($ varTagValueNode ->variableName , '$ ' );
142- if ($ variableName === '' && $ this ->isAllowedEmptyVariableName ($ stmt )) {
143- continue ;
144- }
145- if ($ this ->hasVariableName ($ stmt , $ variableName )) {
146- continue ;
147- }
148- $ comments = $ node ->getComments ();
149- if (isset ($ comments [1 ])) {
150- // skip edge case with double comment, as impossible to resolve by PHPStan doc parser
151- continue ;
135+ $ varTagValueNodes = $ phpDocInfo ->getPhpDocNode ()->getVarTagValues ();
136+ foreach ($ varTagValueNodes as $ varTagValueNode ) {
137+ if ($ this ->isObjectShapePseudoType ($ varTagValueNode )) {
138+ continue ;
139+ }
140+ $ variableName = ltrim ($ varTagValueNode ->variableName , '$ ' );
141+ if ($ variableName === '' && $ this ->isAllowedEmptyVariableName ($ stmt )) {
142+ continue ;
143+ }
144+ if ($ this ->hasVariableName ($ stmt , $ variableName )) {
145+ continue ;
146+ }
147+ $ comments = $ node ->getComments ();
148+ if (isset ($ comments [1 ])) {
149+ // skip edge case with double comment, as impossible to resolve by PHPStan doc parser
150+ continue ;
151+ }
152+ if ($ this ->stmtsManipulator ->isVariableUsedInNextStmt ($ node , $ key + 1 , $ variableName )) {
153+ continue ;
154+ }
155+ if ($ variableName === '' ) {
156+ $ phpDocInfo ->removeByType (VarTagValueNode::class);
157+ } else {
158+ $ phpDocInfo ->removeByType (VarTagValueNode::class, $ variableName );
159+ }
160+ $ hasChangedStmt = \true;
152161 }
153- if ($ this ->stmtsManipulator ->isVariableUsedInNextStmt ($ node , $ key + 1 , $ variableName )) {
154- continue ;
162+ if ($ hasChangedStmt ) {
163+ $ this ->docBlockUpdater ->updateRefactoredNodeWithPhpDocInfo ($ stmt );
164+ $ hasChanged = \true;
155165 }
156- $ phpDocInfo ->removeByType (VarTagValueNode::class);
157- $ this ->docBlockUpdater ->updateRefactoredNodeWithPhpDocInfo ($ stmt );
158- $ hasChanged = \true;
159166 }
160167 if ($ hasChanged ) {
161168 return $ node ;
0 commit comments