File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 4
4
use PhpParser \Comment ;
5
5
use PhpParser \Node ;
6
6
use PhpParser \ParserFactory ;
7
+ use PHPStan \PhpDocParser \Ast \PhpDoc \PhpDocChildNode ;
7
8
use PHPStan \PhpDocParser \Ast \PhpDoc \PhpDocNode ;
8
9
use PHPStan \PhpDocParser \Ast \PhpDoc \PhpDocTagNode ;
9
10
use PHPStan \PhpDocParser \Ast \PhpDoc \ReturnTagValueNode ;
@@ -475,6 +476,26 @@ private function compareFunctions(Node\FunctionLike $old, Node\FunctionLike $new
475
476
}
476
477
}
477
478
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
+
478
499
return [$ new ];
479
500
}
480
501
You can’t perform that action at this time.
0 commit comments