From f79395851b044689567e0e6c9504acbcaa742782 Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Tue, 26 Feb 2019 10:11:12 +1000 Subject: Twig update to latest Twig 1.x legacy as per vichan --- inc/lib/Twig/Node/Expression/Binary/EndsWith.php | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 inc/lib/Twig/Node/Expression/Binary/EndsWith.php (limited to 'inc/lib/Twig/Node/Expression/Binary/EndsWith.php') diff --git a/inc/lib/Twig/Node/Expression/Binary/EndsWith.php b/inc/lib/Twig/Node/Expression/Binary/EndsWith.php new file mode 100644 index 00000000..85c52937 --- /dev/null +++ b/inc/lib/Twig/Node/Expression/Binary/EndsWith.php @@ -0,0 +1,32 @@ +getVarName(); + $right = $compiler->getVarName(); + $compiler + ->raw(sprintf('(is_string($%s = ', $left)) + ->subcompile($this->getNode('left')) + ->raw(sprintf(') && is_string($%s = ', $right)) + ->subcompile($this->getNode('right')) + ->raw(sprintf(') && (\'\' === $%2$s || $%2$s === substr($%1$s, -strlen($%2$s))))', $left, $right)) + ; + } + + public function operator(Twig_Compiler $compiler) + { + return $compiler->raw(''); + } +} + +class_alias('Twig_Node_Expression_Binary_EndsWith', 'Twig\Node\Expression\Binary\EndsWithBinary', false); -- cgit v1.3