From 875378c3f7878231daea4f36dce388aade4d3058 Mon Sep 17 00:00:00 2001 From: Yi-Jyun Pan Date: Wed, 11 Dec 2024 18:12:32 +0800 Subject: [PATCH] Do not pass "$tag" parameter to Twig_Node constructor > Since twig/twig 3.12: The "tag" constructor argument of the "NotFloran\MjmlBundle\Twig\Node" class is deprecated and ignored (check which TokenParser class set it to "mjml"), the tag is now automatically set by the Parser when needed. --- src/Twig/Node.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Twig/Node.php b/src/Twig/Node.php index 57557dc..89445b8 100644 --- a/src/Twig/Node.php +++ b/src/Twig/Node.php @@ -16,12 +16,20 @@ class Node extends Twig_Node */ public function __construct(Twig_Node $value, $line, $tag = null) { + $twigGreaterThan312 = version_compare(\Twig\Environment::VERSION, '3.12', '>='); + if (class_exists(CaptureNode::class)) { - $value = new CaptureNode($value, $line, $tag); + $value = $twigGreaterThan312 + ? new CaptureNode($value, $line) + : new CaptureNode($value, $line, $tag); $value->setAttribute('raw', true); } - parent::__construct(['value' => $value], ['name' => $tag], $line, $tag); + if ($twigGreaterThan312) { + parent::__construct(['value' => $value], ['name' => $tag], $line); + } else { + parent::__construct(['value' => $value], ['name' => $tag], $line, $tag); + } } /**