public function parse(SourceFile $source)
{
$this->found = array();
$this->redeclarations = array();
$this->inNamespace = '';
$this->aliases = array();
$this->bracketLevel = 0;
$this->inUnit = '';
$this->nsBracket = 0;
$this->classBracket = 0;
$this->tokenArray = $source->getTokens();
$tokenCount = count($this->tokenArray);
$tokList = array_keys($this->methodMap);
for ($t = 0; $t < $tokenCount; $t++) {
$current = (array) $this->tokenArray[$t];
if ($current[0] == T_STRING && $current[1] == 'trait' && T_TRAIT == -1) {
// PHP < 5.4 compat fix
$current[0] = T_TRAIT_53;
$this->tokenArray[$t] = $current;
}
if (!in_array($current[0], $tokList)) {
continue;
}
// PHP 5.5 has classname::class, reusing T_CLASS
if ($this->tokenArray[$t - 1][0] == T_DOUBLE_COLON) {
continue;
}
$t = call_user_func(array($this, $this->methodMap[$current[0]]), $t);
}
return new ParseResult($this->found, $this->dependencies, $this->redeclarations);
}