@@ -91,6 +91,21 @@ private function getKeywords(array $tokens, $idx) {
91
91
return implode (', ' , $ keywords );
92
92
}
93
93
94
+ private function getParent (array $ tokens , $ i ) {
95
+ $ parent = false ;
96
+ if ($ this ->tconst ($ tokens [$ i +4 ]) === T_EXTENDS ) {
97
+ $ ci = $ i + 6 ;
98
+ $ className = (string )$ tokens [$ ci ];
99
+
100
+ while (isset ($ tokens [$ ci +1 ]) && !($ this ->tconst ($ tokens [$ ci +1 ]) === T_WHITESPACE )) {
101
+ $ className .= (string )$ tokens [++$ ci ];
102
+ }
103
+
104
+ $ parent = $ className ;
105
+ }
106
+ return $ parent ;
107
+ }
108
+
94
109
public function tokenize () {
95
110
$ sourceCode = file_get_contents ($ this ->filename );
96
111
$ tokens = token_get_all ($ sourceCode );
@@ -116,18 +131,6 @@ public function tokenize() {
116
131
117
132
case 'PHP_Token_CLASS ' :
118
133
case 'PHP_Token_TRAIT ' :
119
- $ parent = false ;
120
- if ($ this ->tconst ($ tokens [$ i +4 ]) === T_EXTENDS ) {
121
- $ ci = $ i + 6 ;
122
- $ className = (string )$ tokens [$ ci ];
123
-
124
- while (isset ($ tokens [$ ci +1 ]) && !($ this ->tconst ($ tokens [$ ci +1 ]) === T_WHITESPACE )) {
125
- $ className .= (string )$ tokens [++$ ci ];
126
- }
127
-
128
- $ parent = $ className ;
129
- }
130
-
131
134
$ interfaces = false ;
132
135
if (isset ($ tokens [$ i + 4 ]) && $ this ->tid ($ tokens [$ i + 4 ]) === T_IMPLEMENTS ||
133
136
isset ($ tokens [$ i + 8 ]) && $ this ->tid ($ tokens [$ i + 8 ]) === T_IMPLEMENTS ) {
@@ -148,7 +151,7 @@ public function tokenize() {
148
151
149
152
$ tmp = array (
150
153
'methods ' => array (),
151
- 'parent ' => $ parent ,
154
+ 'parent ' => $ this -> getParent ( $ tokens , $ i ) ,
152
155
'interfaces ' => $ interfaces ,
153
156
'keywords ' => $ this ->getKeywords ($ tokens , $ i ),
154
157
'docblock ' => $ token ->getDocblock (),
0 commit comments