File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,13 @@ public function __construct($filename) {
45
45
$ this ->filename = $ filename ;
46
46
}
47
47
48
+ private function tconst ($ token ) {
49
+ if (is_array ($ token )) {
50
+ return $ token [0 ];
51
+ }
52
+ return null ;
53
+ }
54
+
48
55
public function tokenize () {
49
56
$ sourceCode = file_get_contents ($ this ->filename );
50
57
$ tokens = token_get_all ($ sourceCode );
@@ -70,9 +77,21 @@ public function tokenize() {
70
77
71
78
case 'PHP_Token_CLASS ' :
72
79
case 'PHP_Token_TRAIT ' :
80
+ $ parent = false ;
81
+ if ($ this ->tconst ($ tokens [$ i +4 ]) === T_EXTENDS ) {
82
+ $ ci = $ i + 6 ;
83
+ $ className = (string )$ tokens [$ ci ];
84
+
85
+ while (isset ($ tokens [$ ci +1 ]) && !($ this ->tconst ($ tokens [$ ci +1 ]) === T_WHITESPACE )) {
86
+ $ className .= (string )$ tokens [++$ ci ];
87
+ }
88
+
89
+ $ parent = $ className ;
90
+ }
91
+
73
92
$ tmp = array (
74
93
'methods ' => array (),
75
- 'parent ' => $ token -> getParent () ,
94
+ 'parent ' => $ parent ,
76
95
'interfaces ' => $ token ->getInterfaces (),
77
96
'keywords ' => $ token ->getKeywords (),
78
97
'docblock ' => $ token ->getDocblock (),
You can’t perform that action at this time.
0 commit comments