File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 44use PhpParser \Comment ;
55use PhpParser \Node ;
66use PhpParser \ParserFactory ;
7+ use PHPStan \PhpDocParser \Ast \PhpDoc \PhpDocChildNode ;
78use PHPStan \PhpDocParser \Ast \PhpDoc \PhpDocNode ;
89use PHPStan \PhpDocParser \Ast \PhpDoc \PhpDocTagNode ;
910use PHPStan \PhpDocParser \Ast \PhpDoc \ReturnTagValueNode ;
@@ -475,6 +476,26 @@ private function compareFunctions(Node\FunctionLike $old, Node\FunctionLike $new
475476 }
476477 }
477478
479+ if (
480+ $ old ->getReturnType () !== null
481+ && $ new ->getReturnType () !== null
482+ && $ new ->getDocComment () !== null
483+ ) {
484+ if ($ old ->getDocComment () === null || $ this ->findPhpDocReturn ($ this ->parseDocComment ($ old ->getDocComment ()->getText ())) === null ) {
485+ $ newPhpDocNode = $ this ->parseDocComment ($ new ->getDocComment ()->getText ());
486+ if ($ this ->findPhpDocReturn ($ newPhpDocNode ) !== null ) {
487+ $ newPhpDocNodeWithoutReturn = new PhpDocNode (array_values (array_filter ($ newPhpDocNode ->children , function (PhpDocChildNode $ child ): bool {
488+ if (!$ child instanceof PhpDocTagNode) {
489+ return true ;
490+ }
491+
492+ return !$ child ->value instanceof ReturnTagValueNode;
493+ })));
494+ $ new ->setDocComment (new Comment \Doc ((string ) $ newPhpDocNodeWithoutReturn ));
495+ }
496+ }
497+ }
498+
478499 return [$ new ];
479500 }
480501
You can’t perform that action at this time.
0 commit comments