/** * * @param array $stackFrame * @return TokenStream */ public function parseStackFrame(array $stackFrame, VarParser $varParser) { $builder = new TokenStreamBuilder(); if (isset($stackFrame['class'])) { $reflect = new \ReflectionClass($stackFrame['class']); $builder->addKeyword($reflect->getShortName(), $stackFrame['class'])->addPunctuation($stackFrame['type']); } if (isset($stackFrame['function'])) { $args = array(); foreach ($stackFrame['args'] as $arg) { $args[] = $varParser->parse($arg, -1); } $builder->addKeyword($stackFrame['function'])->addBrace('('); if (count($args)) { $builder->addStream(array_shift($args)); while (count($args)) { $builder->addPunctuation(',')->addWhitespece()->addStream(array_shift($args)); } } $builder->addBrace(')'); } if (isset($stackFrame['file'])) { if (isset($stackFrame['class']) or isset($stackFrame['function'])) { $builder->addWhitespece()->addPlainText('in')->addWhitespece(); } $builder->addKeyword(basename($stackFrame['file']), $stackFrame['file']); if (isset($stackFrame['line'])) { $builder->addWhitespece()->addPlainText('line')->addWhitespece()->addKeyword($stackFrame['line']); } } return $builder->getStream(); }