1<?php
2
3/*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Twig\TokenParser;
13
14use Twig\Node\DeprecatedNode;
15use Twig\Token;
16
17/**
18 * Deprecates a section of a template.
19 *
20 *    {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
21 *    {% extends 'layout.html.twig' %}
22 *
23 * @author Yonel Ceruto <yonelceruto@gmail.com>
24 *
25 * @final
26 */
27class DeprecatedTokenParser extends AbstractTokenParser
28{
29    public function parse(Token $token)
30    {
31        $expr = $this->parser->getExpressionParser()->parseExpression();
32
33        $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
34
35        return new DeprecatedNode($expr, $token->getLine(), $this->getTag());
36    }
37
38    public function getTag()
39    {
40        return 'deprecated';
41    }
42}
43
44class_alias('Twig\TokenParser\DeprecatedTokenParser', 'Twig_TokenParser_Deprecated');
45