mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 12:37:15 +00:00
Move code from ExtendsTokenParser to Parser
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# 3.12.0 (2024-XX-XX)
|
||||
|
||||
* Deprecate passing `null` to `Twig\Parser::setParent()`
|
||||
* Update `Node::__toString()` to include the node tag if set
|
||||
* Add support for integers in methods of `Twig\Node\Node` that take a Node name
|
||||
* Deprecate not passing a `BodyNode` instance as the body of a `ModuleNode` or `MacroNode` constructor
|
||||
|
||||
@@ -166,6 +166,9 @@ Parser
|
||||
* The ``Twig\ExpressionParser::parseArrayExpression()`` method is deprecated, use
|
||||
``Twig\ExpressionParser::parseSequenceExpression()`` instead.
|
||||
|
||||
* Passing ``null`` to ``Twig\Parser::setParent()`` is deprecated as of Twig
|
||||
3.12.
|
||||
|
||||
Templates
|
||||
---------
|
||||
|
||||
|
||||
@@ -292,6 +292,14 @@ class Parser
|
||||
|
||||
public function setParent(?Node $parent): void
|
||||
{
|
||||
if (null === $parent) {
|
||||
trigger_deprecation('twig/twig', '3.12', 'Passing "null" to "%s()" is deprecated.', __METHOD__);
|
||||
}
|
||||
|
||||
if (null !== $this->parent) {
|
||||
throw new SyntaxError('Multiple extends tags are forbidden.', $parent->getTemplateLine(), $parent->getSourceContext());
|
||||
}
|
||||
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,6 @@ final class ExtendsTokenParser extends AbstractTokenParser
|
||||
throw new SyntaxError('Cannot use "extend" in a macro.', $token->getLine(), $stream->getSourceContext());
|
||||
}
|
||||
|
||||
if (null !== $this->parser->getParent()) {
|
||||
throw new SyntaxError('Multiple extends tags are forbidden.', $token->getLine(), $stream->getSourceContext());
|
||||
}
|
||||
$this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
|
||||
|
||||
$stream->expect(Token::BLOCK_END_TYPE);
|
||||
|
||||
Reference in New Issue
Block a user