Skip to content

Commit a3f24fc

Browse files
committed
WIP inline Class/Trait getInterfaces()
1 parent 3691ad8 commit a3f24fc

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/CodeCoverage/Util/Tokenizer.php

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,18 @@ private function tconst($token) {
5252
return null;
5353
}
5454

55+
private function tclass($token) {
56+
if (is_array($token)) {
57+
$name = substr(token_name($token[0]), 2);
58+
$text = $token[1];
59+
60+
return 'PHP_Token_' . $name;
61+
} else {
62+
$text = $token;
63+
return self::$customTokens[$token];
64+
}
65+
}
66+
5567
public function tokenize() {
5668
$sourceCode = file_get_contents($this->filename);
5769
$tokens = token_get_all($sourceCode);
@@ -89,10 +101,28 @@ public function tokenize() {
89101
$parent = $className;
90102
}
91103

104+
$interfaces = false;
105+
if (isset($tokens[$i + 4]) && $this->tid($tokens[$i + 4]) === T_IMPLEMENTS ||
106+
isset($tokens[$i + 8]) && $this->tid($tokens[$i + 8]) === T_IMPLEMENTS) {
107+
if ($this->tid($tokens[$i + 4]) === T_IMPLEMENTS) {
108+
$ii = $i + 3;
109+
} else {
110+
$ii = $i + 7;
111+
}
112+
113+
while (!$this->tclass($tokens[$ii+1]) === 'PHP_Token_OPEN_CURLY') {
114+
$ii++;
115+
116+
if ($this->tconst($tokens[$ii]) === T_STRING) {
117+
$interfaces[] = (string)$tokens[$ii];
118+
}
119+
}
120+
}
121+
92122
$tmp = array(
93123
'methods' => array(),
94124
'parent' => $parent,
95-
'interfaces'=> $token->getInterfaces(),
125+
'interfaces'=> $interfaces,
96126
'keywords' => $token->getKeywords(),
97127
'docblock' => $token->getDocblock(),
98128
'startLine' => $token->getLine(),

0 commit comments

Comments
 (0)