File tree 2 files changed +18
-3
lines changed
2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ class PhpNodeVisitor implements NodeVisitor
15
15
protected $ validFunctions ;
16
16
protected $ filename ;
17
17
protected $ functions = [];
18
+ protected $ bufferComments = [];
18
19
19
20
public function __construct (string $ filename , array $ validFunctions = null )
20
21
{
@@ -36,9 +37,19 @@ public function enterNode(Node $node)
36
37
$ this ->functions [] = $ this ->createFunction ($ node );
37
38
}
38
39
40
+ $ this ->bufferComments = [];
39
41
return null ;
40
42
}
41
43
44
+ switch ($ node ->getType ()) {
45
+ case 'Stmt_Echo ' :
46
+ case 'Stmt_Return ' :
47
+ case 'Expr_Print ' :
48
+ $ this ->bufferComments = $ node ->getComments ();
49
+ return null ;
50
+ }
51
+
52
+ $ this ->bufferComments = [];
42
53
return null ;
43
54
}
44
55
@@ -70,6 +81,10 @@ protected function createFunction(FuncCall $node): ParsedFunction
70
81
$ function ->addComment (static ::getComment ($ comment ));
71
82
}
72
83
84
+ foreach ($ this ->bufferComments as $ comment ) {
85
+ $ function ->addComment (static ::getComment ($ comment ));
86
+ }
87
+
73
88
foreach ($ node ->args as $ argument ) {
74
89
$ value = $ argument ->value ;
75
90
Original file line number Diff line number Diff line change 1
1
<?php
2
2
//This comment is related with the first function
3
3
4
- fn1 ('arg1 ' , 'arg2 ' , 3 );
4
+ print ( fn1 ('arg1 ' , 'arg2 ' , 3 ) );
5
5
fn2 ($ var );
6
6
fn3 (fn4 ('arg4 ' ), 'arg5 ' , fn5 (6 , 7.5 ));
7
7
fn6 (['arr ' ]);
8
8
fn7 (CONSTANT_1 );
9
9
// fn_8();
10
10
/* ALLOW: This is a comment to fn9 */
11
- fn9 (ARG_8 );
11
+ return fn9 (ARG_8 );
12
12
13
13
/* Comment to fn10 */ fn10 ();
14
14
19
19
Related comment
20
20
number one
21
21
*/
22
- fn12 (
22
+ echo fn12 (
23
23
/* Related comment 2 */
24
24
'arg11 ' ,
25
25
/* ALLOW: Related comment 3 */
You can’t perform that action at this time.
0 commit comments