class PHP_Token_INTERFACE in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/phpunit/php-token-stream/src/Token.php \PHP_Token_INTERFACE
Hierarchy
- class \PHP_Token
- class \PHP_TokenWithScope
- class \PHP_TokenWithScopeAndVisibility
- class \PHP_Token_INTERFACE
- class \PHP_TokenWithScopeAndVisibility
- class \PHP_TokenWithScope
Expanded class hierarchy of PHP_Token_INTERFACE
2 string references to 'PHP_Token_INTERFACE'
- PHP_CodeCoverage::getLinesToBeIgnored in vendor/
phpunit/ php-code-coverage/ src/ CodeCoverage.php - Returns the lines of a source file that should be ignored.
- PHP_Token_Stream::parse in vendor/
phpunit/ php-token-stream/ src/ Token/ Stream.php
File
- vendor/
phpunit/ php-token-stream/ src/ Token.php, line 444
View source
class PHP_Token_INTERFACE extends PHP_TokenWithScopeAndVisibility {
/**
* @var array
*/
protected $interfaces;
/**
* @return string
*/
public function getName() {
return (string) $this->tokenStream[$this->id + 2];
}
/**
* @return boolean
*/
public function hasParent() {
return $this->tokenStream[$this->id + 4] instanceof PHP_Token_EXTENDS;
}
/**
* @return array
*/
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;
}
/**
* @param array $parts
* @param string $join
* @return string
*/
protected function arrayToName(array $parts, $join = '\\') {
$result = '';
if (count($parts) > 1) {
array_pop($parts);
$result = join($join, $parts);
}
return $result;
}
/**
* @return boolean|string
*/
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;
}
/**
* @return boolean
*/
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;
}
/**
* @return array|boolean
*/
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;
}
}