Expanded class hierarchy of PHP_Token_INTERFACE
class PHP_Token_INTERFACE extends PHP_TokenWithScopeAndVisibility {
protected $interfaces;
public function getName() {
return (string) $this->tokenStream[$this->id + 2];
}
public function hasParent() {
return $this->tokenStream[$this->id + 4] instanceof PHP_Token_EXTENDS;
}
public function getPackage() {
$className = $this
->getName();
$docComment = $this
->getDocblock();
$result = array(
'namespace' => '',
'fullPackage' => '',
'category' => '',
'package' => '',
'subpackage' => '',
);
for ($i = $this->id; $i; --$i) {
if ($this->tokenStream[$i] instanceof PHP_Token_NAMESPACE) {
$result['namespace'] = $this->tokenStream[$i]
->getName();
break;
}
}
if (preg_match('/@category[\\s]+([\\.\\w]+)/', $docComment, $matches)) {
$result['category'] = $matches[1];
}
if (preg_match('/@package[\\s]+([\\.\\w]+)/', $docComment, $matches)) {
$result['package'] = $matches[1];
$result['fullPackage'] = $matches[1];
}
if (preg_match('/@subpackage[\\s]+([\\.\\w]+)/', $docComment, $matches)) {
$result['subpackage'] = $matches[1];
$result['fullPackage'] .= '.' . $matches[1];
}
if (empty($result['fullPackage'])) {
$result['fullPackage'] = $this
->arrayToName(explode('_', str_replace('\\', '_', $className)), '.');
}
return $result;
}
protected function arrayToName(array $parts, $join = '\\') {
$result = '';
if (count($parts) > 1) {
array_pop($parts);
$result = join($join, $parts);
}
return $result;
}
public function getParent() {
if (!$this
->hasParent()) {
return FALSE;
}
$i = $this->id + 6;
$tokens = $this->tokenStream
->tokens();
$className = (string) $tokens[$i];
while (isset($tokens[$i + 1]) && !$tokens[$i + 1] instanceof PHP_Token_WHITESPACE) {
$className .= (string) $tokens[++$i];
}
return $className;
}
public function hasInterfaces() {
return isset($this->tokenStream[$this->id + 4]) && $this->tokenStream[$this->id + 4] instanceof PHP_Token_IMPLEMENTS || isset($this->tokenStream[$this->id + 8]) && $this->tokenStream[$this->id + 8] instanceof PHP_Token_IMPLEMENTS;
}
public function getInterfaces() {
if ($this->interfaces !== NULL) {
return $this->interfaces;
}
if (!$this
->hasInterfaces()) {
return $this->interfaces = FALSE;
}
if ($this->tokenStream[$this->id + 4] instanceof PHP_Token_IMPLEMENTS) {
$i = $this->id + 3;
}
else {
$i = $this->id + 7;
}
$tokens = $this->tokenStream
->tokens();
while (!$tokens[$i + 1] instanceof PHP_Token_OPEN_CURLY) {
$i++;
if ($tokens[$i] instanceof PHP_Token_STRING) {
$this->interfaces[] = (string) $tokens[$i];
}
}
return $this->interfaces;
}
}