public function PHP_Token_INTERFACE::getPackage in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpunit/php-token-stream/src/Token.php \PHP_Token_INTERFACE::getPackage()
Return value
array
File
- vendor/
phpunit/ php-token-stream/ src/ Token.php, line 470
Class
Code
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;
}