From e24f796b83fed1b223d7452a56b0bda28f671c29 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 23 Mar 2019 14:36:22 +0100 Subject: [PATCH] fixed CheckToStringNode implementation --- CHANGELOG | 2 +- src/Node/CheckToStringNode.php | 2 +- test/Twig/Tests/Fixtures/tags/sandbox/array.test | 16 ++++++++++++++++ test/Twig/Tests/IntegrationTest.php | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 test/Twig/Tests/Fixtures/tags/sandbox/array.test diff --git a/CHANGELOG b/CHANGELOG index 7798f3372..61b1c32be 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 1.38.4 (2019-XX-XX) - * n/a + * fixed CheckToStringNode implementation (broken when a function/filter is variadic) * 1.38.3 (2019-03-21) diff --git a/src/Node/CheckToStringNode.php b/src/Node/CheckToStringNode.php index 464c96fba..5d6746791 100644 --- a/src/Node/CheckToStringNode.php +++ b/src/Node/CheckToStringNode.php @@ -24,7 +24,7 @@ use Twig\Node\Expression\AbstractExpression; * * @author Fabien Potencier */ -class CheckToStringNode extends Node +class CheckToStringNode extends AbstractExpression { public function __construct(AbstractExpression $expr) { diff --git a/test/Twig/Tests/Fixtures/tags/sandbox/array.test b/test/Twig/Tests/Fixtures/tags/sandbox/array.test new file mode 100644 index 000000000..b432427e4 --- /dev/null +++ b/test/Twig/Tests/Fixtures/tags/sandbox/array.test @@ -0,0 +1,16 @@ +--TEST-- +sandbox tag +--TEMPLATE-- +{%- sandbox %} + {%- include "foo.twig" %} +{%- endsandbox %} +--TEMPLATE(foo.twig)-- +{{ [a][0] }} +{{ dump([a][0]) }} +--DATA-- +return ['a' => 'b'] +--CONFIG-- +return ['autoescape' => false, 'debug' => true] +--EXPECT-- +b +string(1) "b" diff --git a/test/Twig/Tests/IntegrationTest.php b/test/Twig/Tests/IntegrationTest.php index be25047c8..3d9a14cdd 100644 --- a/test/Twig/Tests/IntegrationTest.php +++ b/test/Twig/Tests/IntegrationTest.php @@ -34,7 +34,7 @@ class Twig_Tests_IntegrationTest extends IntegrationTestCase { public function getExtensions() { - $policy = new SecurityPolicy([], [], [], [], []); + $policy = new SecurityPolicy([], [], [], [], ['dump']); return [ new DebugExtension(),