public function TokenParser::parseUseStatement in Service Container 7
Same name and namespace in other branches
- 7.2 modules/providers/service_container_annotation_discovery/lib/Doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php \Doctrine\Common\Annotations\TokenParser::parseUseStatement()
Parses a single use statement.
Return value
array A list with all found class names for a use statement.
1 call to TokenParser::parseUseStatement()
- TokenParser::parseUseStatements in modules/
providers/ service_container_annotation_discovery/ lib/ Doctrine/ annotations/ lib/ Doctrine/ Common/ Annotations/ TokenParser.php - Gets all use statements.
File
- modules/
providers/ service_container_annotation_discovery/ lib/ Doctrine/ annotations/ lib/ Doctrine/ Common/ Annotations/ TokenParser.php, line 100
Class
- TokenParser
- Parses a file for namespaces/use/class declarations.
Namespace
Doctrine\Common\AnnotationsCode
public function parseUseStatement() {
$class = '';
$alias = '';
$statements = array();
$explicitAlias = false;
while ($token = $this
->next()) {
$isNameToken = $token[0] === T_STRING || $token[0] === T_NS_SEPARATOR;
if (!$explicitAlias && $isNameToken) {
$class .= $token[1];
$alias = $token[1];
}
else {
if ($explicitAlias && $isNameToken) {
$alias .= $token[1];
}
else {
if ($token[0] === T_AS) {
$explicitAlias = true;
$alias = '';
}
else {
if ($token === ',') {
$statements[strtolower($alias)] = $class;
$class = '';
$alias = '';
$explicitAlias = false;
}
else {
if ($token === ';') {
$statements[strtolower($alias)] = $class;
break;
}
else {
break;
}
}
}
}
}
}
return $statements;
}