/** * @param Parser $parser * @param Stream $stream * @param $parentTemplate * * @return ClassNode */ private function parseClass(Parser $parser, Stream $stream, $parentTemplate) { $oldClassNode = $parser->getCurrentClassNode(); $fileNode = $parser->getCurrentFileNode(); /** @var $classNode ClassNode */ $classNode = $fileNode->addClass($fileNode->getNextEmbeddedTemplateName()); $classNode->setParentTemplate($parentTemplate); $parser->setCurrentClassNode($classNode); $classNode->addChild($parser->parseBlock($stream, 'endembed'), ClassNode::MAIN_TEMPLATE_BLOCK); $stream->expect(Token::TAG_END); $parser->setCurrentClassNode($oldClassNode); return $classNode->getClassName(); }