File tree Expand file tree Collapse file tree 12 files changed +73
-39
lines changed Expand file tree Collapse file tree 12 files changed +73
-39
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace PhpParser ;
4
4
5
+ use PhpParser \Node \Stmt \Class_ ;
6
+
5
7
class NodeDumper
6
8
{
7
9
private $ dumpComments ;
@@ -38,7 +40,11 @@ public function dump($node) {
38
40
} elseif (true === $ value ) {
39
41
$ r .= 'true ' ;
40
42
} elseif (is_scalar ($ value )) {
41
- $ r .= $ value ;
43
+ if ('flags ' === $ key || 'newModifier ' === $ key ) {
44
+ $ r .= $ this ->dumpFlags ($ value );
45
+ } else {
46
+ $ r .= $ value ;
47
+ }
42
48
} else {
43
49
$ r .= str_replace ("\n" , "\n " , $ this ->dump ($ value ));
44
50
}
@@ -73,4 +79,32 @@ public function dump($node) {
73
79
74
80
return $ r . "\n) " ;
75
81
}
82
+
83
+ protected function dumpFlags ($ flags ) {
84
+ $ strs = [];
85
+ if ($ flags & Class_::MODIFIER_PUBLIC ) {
86
+ $ strs [] = 'MODIFIER_PUBLIC ' ;
87
+ }
88
+ if ($ flags & Class_::MODIFIER_PROTECTED ) {
89
+ $ strs [] = 'MODIFIER_PROTECTED ' ;
90
+ }
91
+ if ($ flags & Class_::MODIFIER_PRIVATE ) {
92
+ $ strs [] = 'MODIFIER_PRIVATE ' ;
93
+ }
94
+ if ($ flags & Class_::MODIFIER_ABSTRACT ) {
95
+ $ strs [] = 'MODIFIER_ABSTRACT ' ;
96
+ }
97
+ if ($ flags & Class_::MODIFIER_STATIC ) {
98
+ $ strs [] = 'MODIFIER_STATIC ' ;
99
+ }
100
+ if ($ flags & Class_::MODIFIER_FINAL ) {
101
+ $ strs [] = 'MODIFIER_FINAL ' ;
102
+ }
103
+
104
+ if ($ strs ) {
105
+ return implode (' | ' , $ strs ) . ' ( ' . $ flags . ') ' ;
106
+ } else {
107
+ return $ flags ;
108
+ }
109
+ }
76
110
}
Original file line number Diff line number Diff line change 81
81
)
82
82
)
83
83
2: Stmt_ClassMethod(
84
- flags: 8
84
+ flags: MODIFIER_STATIC (8)
85
85
byRef: false
86
86
name: list
87
87
params: array(
91
91
)
92
92
)
93
93
3: Stmt_ClassMethod(
94
- flags: 8
94
+ flags: MODIFIER_STATIC (8)
95
95
byRef: false
96
96
name: protected
97
97
params: array(
@@ -101,7 +101,7 @@ array(
101
101
)
102
102
)
103
103
4: Stmt_Property(
104
- flags: 1
104
+ flags: MODIFIER_PUBLIC (1)
105
105
props: array(
106
106
0: Stmt_PropertyProperty(
107
107
name: class
@@ -110,7 +110,7 @@ array(
110
110
)
111
111
)
112
112
5: Stmt_Property(
113
- flags: 1
113
+ flags: MODIFIER_PUBLIC (1)
114
114
props: array(
115
115
0: Stmt_PropertyProperty(
116
116
name: private
@@ -321,7 +321,7 @@ array(
321
321
)
322
322
)
323
323
method: throw
324
- newModifier: 2
324
+ newModifier: MODIFIER_PROTECTED (2)
325
325
newName: public
326
326
)
327
327
3: Stmt_TraitUseAdaptation_Alias(
@@ -331,7 +331,7 @@ array(
331
331
)
332
332
)
333
333
method: self
334
- newModifier: 2
334
+ newModifier: MODIFIER_PROTECTED (2)
335
335
newName: null
336
336
)
337
337
4: Stmt_TraitUseAdaptation_Alias(
Original file line number Diff line number Diff line change @@ -9,14 +9,14 @@ abstract class A {
9
9
-----
10
10
array(
11
11
0: Stmt_Class(
12
- flags: 16
12
+ flags: MODIFIER_ABSTRACT (16)
13
13
name: A
14
14
extends: null
15
15
implements: array(
16
16
)
17
17
stmts: array(
18
18
0: Stmt_ClassMethod(
19
- flags: 1
19
+ flags: MODIFIER_PUBLIC (1)
20
20
byRef: false
21
21
name: a
22
22
params: array(
26
26
)
27
27
)
28
28
1: Stmt_ClassMethod(
29
- flags: 17
29
+ flags: MODIFIER_PUBLIC | MODIFIER_ABSTRACT (17)
30
30
byRef: false
31
31
name: b
32
32
params: array(
Original file line number Diff line number Diff line change 31
31
)
32
32
stmts: array(
33
33
0: Stmt_ClassMethod(
34
- flags: 1
34
+ flags: MODIFIER_PUBLIC (1)
35
35
byRef: false
36
36
name: test
37
37
params: array(
81
81
)
82
82
stmts: array(
83
83
0: Stmt_Property(
84
- flags: 1
84
+ flags: MODIFIER_PUBLIC (1)
85
85
props: array(
86
86
0: Stmt_PropertyProperty(
87
87
name: foo
@@ -144,7 +144,7 @@ array(
144
144
)
145
145
stmts: array(
146
146
0: Stmt_ClassMethod(
147
- flags: 1
147
+ flags: MODIFIER_PUBLIC (1)
148
148
byRef: false
149
149
name: test
150
150
params: array(
Original file line number Diff line number Diff line change 30
30
)
31
31
)
32
32
1: Stmt_ClassConst(
33
- flags: 1
33
+ flags: MODIFIER_PUBLIC (1)
34
34
consts: array(
35
35
0: Const(
36
36
name: B
41
41
)
42
42
)
43
43
2: Stmt_ClassConst(
44
- flags: 2
44
+ flags: MODIFIER_PROTECTED (2)
45
45
consts: array(
46
46
0: Const(
47
47
name: C
52
52
)
53
53
)
54
54
3: Stmt_ClassConst(
55
- flags: 4
55
+ flags: MODIFIER_PRIVATE (4)
56
56
consts: array(
57
57
0: Const(
58
58
name: D
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ final class A {}
6
6
-----
7
7
array(
8
8
0: Stmt_Class(
9
- flags: 32
9
+ flags: MODIFIER_FINAL (32)
10
10
name: A
11
11
extends: null
12
12
implements: array(
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ abstract class A {
14
14
-----
15
15
array(
16
16
0: Stmt_Class(
17
- flags: 16
17
+ flags: MODIFIER_ABSTRACT (16)
18
18
name: A
19
19
extends: null
20
20
implements: array(
30
30
)
31
31
)
32
32
1: Stmt_Property(
33
- flags: 8
33
+ flags: MODIFIER_STATIC (8)
34
34
props: array(
35
35
0: Stmt_PropertyProperty(
36
36
name: b
39
39
)
40
40
)
41
41
2: Stmt_ClassMethod(
42
- flags: 16
42
+ flags: MODIFIER_ABSTRACT (16)
43
43
byRef: false
44
44
name: c
45
45
params: array(
48
48
stmts: null
49
49
)
50
50
3: Stmt_ClassMethod(
51
- flags: 32
51
+ flags: MODIFIER_FINAL (32)
52
52
byRef: false
53
53
name: d
54
54
params: array(
58
58
)
59
59
)
60
60
4: Stmt_ClassMethod(
61
- flags: 8
61
+ flags: MODIFIER_STATIC (8)
62
62
byRef: false
63
63
name: e
64
64
params: array(
68
68
)
69
69
)
70
70
5: Stmt_ClassMethod(
71
- flags: 40
71
+ flags: MODIFIER_STATIC | MODIFIER_FINAL (40)
72
72
byRef: false
73
73
name: f
74
74
params: array(
Original file line number Diff line number Diff line change 23
23
)
24
24
stmts: array(
25
25
0: Stmt_ClassMethod(
26
- flags: 1
26
+ flags: MODIFIER_PUBLIC (1)
27
27
byRef: false
28
28
name: a
29
29
params: array(
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ Cannot use the final modifier on an abstract class member on line 1
30
30
Syntax error, unexpected T_FINAL, expecting T_CLASS from 1:16 to 1:20
31
31
array(
32
32
0: Stmt_Class(
33
- flags: 32
33
+ flags: MODIFIER_FINAL (32)
34
34
name: A
35
35
extends: null
36
36
implements: array(
Original file line number Diff line number Diff line change 36
36
)
37
37
)
38
38
2: Stmt_ClassMethod(
39
- flags: 24
39
+ flags: MODIFIER_ABSTRACT | MODIFIER_STATIC (24)
40
40
byRef: false
41
41
name: baz
42
42
params: array(
You can’t perform that action at this time.
0 commit comments