@@ -135,6 +135,31 @@ private function getInterfaces(array $tokens, $i) {
135
135
return $ interfaces ;
136
136
}
137
137
138
+ /**
139
+ * @return string
140
+ */
141
+ private function getVisibility (array $ tokens , $ idx )
142
+ {
143
+ for ($ i = $ idx - 2 ; $ i > $ idx - 7 ; $ i -= 2 ) {
144
+ if (isset ($ tokens [$ i ])) {
145
+ $ tconst = $ this ->tconst ($ tokens [$ i ]);
146
+
147
+ if ($ tconst === T_PRIVATE ) {
148
+ return "private " ;
149
+ } else if ($ tconst === T_PROTECTED ) {
150
+ return "protected " ;
151
+ }else if ($ tconst === T_PUBLIC ) {
152
+ return "public " ;
153
+ }
154
+
155
+ if (!($ tconst === T_STATIC || $ tconst === T_FINAL || $ tconst === T_ABSTRACT )) {
156
+ // no keywords; stop visibility search
157
+ break ;
158
+ }
159
+ }
160
+ }
161
+ }
162
+
138
163
public function tokenize () {
139
164
$ sourceCode = file_get_contents ($ this ->filename );
140
165
$ tokens = token_get_all ($ sourceCode );
@@ -206,7 +231,7 @@ public function tokenize() {
206
231
$ tmp = array (
207
232
'docblock ' => $ token ->getDocblock (),
208
233
'keywords ' => $ this ->getKeywords ($ tokens , $ i ),
209
- 'visibility ' => $ token ->getVisibility (),
234
+ 'visibility ' => $ this ->getVisibility ($ tokens , $ i ),
210
235
'signature ' => $ token ->getSignature (),
211
236
'startLine ' => $ this ->tline ($ token ),
212
237
'endLine ' => $ token ->getEndLine (),
0 commit comments