@@ -64,6 +64,33 @@ private function tclass($token) {
64
64
}
65
65
}
66
66
67
+ /**
68
+ * @return string
69
+ */
70
+ private function getKeywords (array $ tokens , $ idx ) {
71
+ $ keywords = array ();
72
+
73
+ for ($ i = $ idx - 2 ; $ i > $ idx - 7 ; $ i -= 2 ) {
74
+ if (isset ($ tokens [$ i ])) {
75
+ $ tconst = $ this ->tconst ($ tokens [$ i ]);
76
+
77
+ if ($ tconst === T_PRIVATE || $ tconst === T_PROTECTED || $ tconst === T_PUBLIC ) {
78
+ continue ;
79
+ }
80
+
81
+ if ($ tconst === T_STATIC ) {
82
+ $ keywords [] = 'static ' ;
83
+ } else if ($ tconst === T_FINAL ) {
84
+ $ keywords [] = 'final ' ;
85
+ } else if ($ tconst === T_ABSTRACT ) {
86
+ $ keywords [] = 'abstract ' ;
87
+ }
88
+ }
89
+ }
90
+
91
+ return implode (', ' , $ keywords );
92
+ }
93
+
67
94
public function tokenize () {
68
95
$ sourceCode = file_get_contents ($ this ->filename );
69
96
$ tokens = token_get_all ($ sourceCode );
@@ -123,7 +150,7 @@ public function tokenize() {
123
150
'methods ' => array (),
124
151
'parent ' => $ parent ,
125
152
'interfaces ' => $ interfaces ,
126
- 'keywords ' => $ token ->getKeywords (),
153
+ 'keywords ' => $ this ->getKeywords ($ tokens , $ i ),
127
154
'docblock ' => $ token ->getDocblock (),
128
155
'startLine ' => $ token ->getLine (),
129
156
'endLine ' => $ token ->getEndLine (),
@@ -146,7 +173,7 @@ public function tokenize() {
146
173
$ name = $ token ->getName ();
147
174
$ tmp = array (
148
175
'docblock ' => $ token ->getDocblock (),
149
- 'keywords ' => $ token ->getKeywords (),
176
+ 'keywords ' => $ this ->getKeywords ($ tokens , $ i ),
150
177
'visibility ' => $ token ->getVisibility (),
151
178
'signature ' => $ token ->getSignature (),
152
179
'startLine ' => $ token ->getLine (),
0 commit comments