1111use PhpParser \Node \Stmt \Function_ ;
1212use PhpParser \Node \Stmt \Property ;
1313use PHPStan \PhpDocParser \Ast \Node as AstNode ;
14+ use PHPStan \PhpDocParser \Ast \NodeTraverser ;
1415use PHPStan \PhpDocParser \Ast \PhpDoc \ParamTagValueNode ;
1516use PHPStan \PhpDocParser \Ast \PhpDoc \PhpDocTagNode ;
1617use PHPStan \PhpDocParser \Ast \PhpDoc \ReturnTagValueNode ;
1920use Rector \BetterPhpDocParser \PhpDocInfo \PhpDocInfo ;
2021use Rector \BetterPhpDocParser \PhpDocInfo \PhpDocInfoFactory ;
2122use Rector \Comments \NodeDocBlock \DocBlockUpdater ;
22- use Rector \PhpDocParser \PhpDocParser \PhpDocNodeTraverser ;
23+ use Rector \PhpDocParser \PhpDocParser \PhpDocNodeVisitor \ CallablePhpDocNodeVisitor ;
2324use Rector \Rector \AbstractRector ;
2425use Rector \RuleDoc \CodeSample \CodeSample ;
2526use Rector \RuleDoc \RuleDefinition ;
@@ -137,10 +138,7 @@ private function isNull(VarTagValueNode|ParamTagValueNode|ReturnTagValueNode $ta
137138 */
138139 private function removeParamNullTag (PhpDocInfo $ phpDocInfo , array $ paramNames ): void
139140 {
140- $ phpDocNodeTraverser = new PhpDocNodeTraverser ();
141- $ phpDocNodeTraverser ->traverseWithCallable (
142- $ phpDocInfo ->getPhpDocNode (),
143- '' ,
141+ $ phpDocNodeTraverser = new NodeTraverser ([new CallablePhpDocNodeVisitor (
144142 static function (AstNode $ astNode ) use ($ paramNames ): ?int {
145143 if (! $ astNode instanceof PhpDocTagNode) {
146144 return null ;
@@ -151,12 +149,13 @@ static function (AstNode $astNode) use ($paramNames): ?int {
151149 }
152150
153151 if (in_array ($ astNode ->value ->parameterName , $ paramNames , true )) {
154- return PhpDocNodeTraverser:: NODE_REMOVE ;
152+ return NodeTraverser:: REMOVE_NODE ;
155153 }
156154
157155 return null ;
158156 }
159- );
157+ )]);
158+ $ phpDocNodeTraverser ->traverse ([$ phpDocInfo ->getPhpDocNode ()]);
160159 }
161160
162161 /**
0 commit comments