mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
Deprecate passing a non-AbstractExpression node to Parser::setParent()
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# 3.24.0 (2026-XX-XX)
|
||||
|
||||
* Deprecate passing a non-`AbstractExpression` node to `Parser::setParent()`
|
||||
* Add support for renaming variables in object destructuring (`{name: userName} = user`)
|
||||
* Add `html_attr_relaxed` escaping strategy that preserves :, @, [, and ] for front-end framework attribute names
|
||||
* Add support for short-circuiting in null-safe operator chains
|
||||
|
||||
@@ -238,6 +238,10 @@ Parser
|
||||
* Passing ``null`` to ``Twig\Parser::setParent()`` is deprecated as of Twig
|
||||
3.12.
|
||||
|
||||
* Passing a non-``AbstractExpression`` node to ``Twig\Parser::setParent()`` is
|
||||
deprecated as of Twig 3.24; the method will require an ``AbstractExpression``
|
||||
instance in Twig 4.0.
|
||||
|
||||
* The ``Twig\Parser::getExpressionParser()`` method is deprecated as of Twig
|
||||
3.21, use ``Twig\Parser::parseExpression()`` instead.
|
||||
|
||||
|
||||
@@ -416,6 +416,10 @@ class Parser
|
||||
trigger_deprecation('twig/twig', '3.12', 'Passing "null" to "%s()" is deprecated.', __METHOD__);
|
||||
}
|
||||
|
||||
if (null !== $parent && !$parent instanceof AbstractExpression) {
|
||||
trigger_deprecation('twig/twig', '3.24', 'Passing a "%s" instance to "%s()" is deprecated, pass an "AbstractExpression" instance instead.', $parent::class, __METHOD__);
|
||||
}
|
||||
|
||||
if (null !== $this->parent) {
|
||||
throw new SyntaxError('Multiple extends tags are forbidden.', $parent->getTemplateLine(), $parent->getSourceContext());
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ use Twig\Error\SyntaxError;
|
||||
use Twig\Lexer;
|
||||
use Twig\Loader\ArrayLoader;
|
||||
use Twig\Node\EmptyNode;
|
||||
use Twig\Node\Expression\ConstantExpression;
|
||||
use Twig\Node\Node;
|
||||
use Twig\Node\Nodes;
|
||||
use Twig\Node\SetNode;
|
||||
@@ -208,7 +209,7 @@ EOF, 'index')));
|
||||
protected function getParser()
|
||||
{
|
||||
$parser = new Parser(new Environment(new ArrayLoader()));
|
||||
$parser->setParent(new EmptyNode());
|
||||
$parser->setParent(new ConstantExpression('base.html', 1));
|
||||
|
||||
$p = new \ReflectionProperty($parser, 'stream');
|
||||
$p->setValue($parser, new TokenStream([], new Source('', '')));
|
||||
|
||||
Reference in New Issue
Block a user