blob: 31416c79c1576e85422e091e7e2e90c2a8729b3f [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001<?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\Node\Node;
16use Twig\Token;
17
18/**
19 * Deprecates a section of a template.
20 *
21 * {% deprecated 'The "base.twig" template is deprecated, use "layout.twig" instead.' %}
22 * {% extends 'layout.html.twig' %}
23 *
24 * @author Yonel Ceruto <yonelceruto@gmail.com>
25 *
26 * @internal
27 */
28final class DeprecatedTokenParser extends AbstractTokenParser
29{
30 public function parse(Token $token): Node
31 {
32 $expr = $this->parser->getExpressionParser()->parseExpression();
33
34 $this->parser->getStream()->expect(Token::BLOCK_END_TYPE);
35
36 return new DeprecatedNode($expr, $token->getLine(), $this->getTag());
37 }
38
39 public function getTag(): string
40 {
41 return 'deprecated';
42 }
43}