public function PhpParser::parseClass in Plug 7
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
- 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;
}