public function PhpParser::parseClass in Service Container 7.2
Same name and namespace in other branches
- 7 modules/providers/service_container_annotation_discovery/lib/Doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php \Doctrine\Common\Annotations\PhpParser::parseClass()
Parses a class.
Parameters
\ReflectionClass $class A <code>ReflectionClass</code> object.:
Return value
array A list with use statements in the form (Alias => FQN).
File
- modules/
providers/ service_container_annotation_discovery/ lib/ Doctrine/ annotations/ lib/ Doctrine/ Common/ Annotations/ PhpParser.php, line 39
Class
- PhpParser
- Parses a file for namespaces/use/class declarations.
Namespace
Doctrine\Common\AnnotationsCode
public function parseClass(\ReflectionClass $class) {
if (method_exists($class, 'getUseStatements')) {
return $class
->getUseStatements();
}
if (false === ($filename = $class
->getFilename())) {
return array();
}
$content = $this
->getFileContent($filename, $class
->getStartLine());
if (null === $content) {
return array();
}
$namespace = preg_quote($class
->getNamespaceName());
$content = preg_replace('/^.*?(\\bnamespace\\s+' . $namespace . '\\s*[;{].*)$/s', '\\1', $content);
$tokenizer = new TokenParser('<?php ' . $content);
$statements = $tokenizer
->parseUseStatements($class
->getNamespaceName());
return $statements;
}