summaryrefslogtreecommitdiff
path: root/inc/lib/Twig/Node
diff options
context:
space:
mode:
authorAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:22:40 +1000
committerAppleman1234 <applemansigloo@gmail.com>2022-09-25 13:22:40 +1000
commit92561d7f36508b7e0271926e417adf0e2e53916b (patch)
treea8588b4f70af276c5acf58836e33b1f6ff5c61e8 /inc/lib/Twig/Node
parent6f1083e4b51fc9c4c594f6c72cf3d84ef4d0298b (diff)
Initial attempt a switch to composer and PHP-8.1 compatibility
Diffstat (limited to 'inc/lib/Twig/Node')
-rw-r--r--inc/lib/Twig/Node/AutoEscape.php36
-rw-r--r--inc/lib/Twig/Node/Block.php41
-rw-r--r--inc/lib/Twig/Node/BlockReference.php34
-rw-r--r--inc/lib/Twig/Node/Body.php21
-rw-r--r--inc/lib/Twig/Node/CheckSecurity.php80
-rw-r--r--inc/lib/Twig/Node/Do.php35
-rw-r--r--inc/lib/Twig/Node/Embed.php46
-rw-r--r--inc/lib/Twig/Node/Expression.php22
-rw-r--r--inc/lib/Twig/Node/Expression/Array.php83
-rw-r--r--inc/lib/Twig/Node/Expression/AssignName.php25
-rw-r--r--inc/lib/Twig/Node/Expression/Binary.php37
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Add.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/And.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/BitwiseAnd.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/BitwiseOr.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/BitwiseXor.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Concat.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Div.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/EndsWith.php32
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Equal.php19
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/FloorDiv.php26
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Greater.php19
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/GreaterEqual.php19
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/In.php30
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Less.php19
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/LessEqual.php19
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Matches.php30
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Mod.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Mul.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/NotEqual.php19
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/NotIn.php30
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Or.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Power.php34
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Range.php30
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/StartsWith.php32
-rw-r--r--inc/lib/Twig/Node/Expression/Binary/Sub.php20
-rw-r--r--inc/lib/Twig/Node/Expression/BlockReference.php93
-rw-r--r--inc/lib/Twig/Node/Expression/Call.php291
-rw-r--r--inc/lib/Twig/Node/Expression/Conditional.php33
-rw-r--r--inc/lib/Twig/Node/Expression/Constant.php25
-rw-r--r--inc/lib/Twig/Node/Expression/ExtensionReference.php32
-rw-r--r--inc/lib/Twig/Node/Expression/Filter.php41
-rw-r--r--inc/lib/Twig/Node/Expression/Filter/Default.php45
-rw-r--r--inc/lib/Twig/Node/Expression/Function.php45
-rw-r--r--inc/lib/Twig/Node/Expression/GetAttr.php74
-rw-r--r--inc/lib/Twig/Node/Expression/MacroCall.php60
-rw-r--r--inc/lib/Twig/Node/Expression/MethodCall.php43
-rw-r--r--inc/lib/Twig/Node/Expression/Name.php102
-rw-r--r--inc/lib/Twig/Node/Expression/NullCoalesce.php48
-rw-r--r--inc/lib/Twig/Node/Expression/Parent.php44
-rw-r--r--inc/lib/Twig/Node/Expression/TempName.php28
-rw-r--r--inc/lib/Twig/Node/Expression/Test.php42
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Constant.php48
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Defined.php61
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Divisibleby.php35
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Even.php34
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Null.php33
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Odd.php34
-rw-r--r--inc/lib/Twig/Node/Expression/Test/Sameas.php31
-rw-r--r--inc/lib/Twig/Node/Expression/Unary.php29
-rw-r--r--inc/lib/Twig/Node/Expression/Unary/Neg.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Unary/Not.php20
-rw-r--r--inc/lib/Twig/Node/Expression/Unary/Pos.php20
-rw-r--r--inc/lib/Twig/Node/Flush.php33
-rw-r--r--inc/lib/Twig/Node/For.php113
-rw-r--r--inc/lib/Twig/Node/ForLoop.php52
-rw-r--r--inc/lib/Twig/Node/If.php68
-rw-r--r--inc/lib/Twig/Node/Import.php51
-rw-r--r--inc/lib/Twig/Node/Include.php90
-rw-r--r--inc/lib/Twig/Node/Macro.php125
-rw-r--r--inc/lib/Twig/Node/Module.php461
-rw-r--r--inc/lib/Twig/Node/Print.php36
-rw-r--r--inc/lib/Twig/Node/Sandbox.php44
-rw-r--r--inc/lib/Twig/Node/SandboxedModule.php60
-rw-r--r--inc/lib/Twig/Node/SandboxedPrint.php51
-rw-r--r--inc/lib/Twig/Node/Set.php98
-rw-r--r--inc/lib/Twig/Node/SetTemp.php40
-rw-r--r--inc/lib/Twig/Node/Spaceless.php37
-rw-r--r--inc/lib/Twig/Node/Text.php36
-rw-r--r--inc/lib/Twig/Node/With.php64
80 files changed, 0 insertions, 3908 deletions
diff --git a/inc/lib/Twig/Node/AutoEscape.php b/inc/lib/Twig/Node/AutoEscape.php
deleted file mode 100644
index 17e4e381..00000000
--- a/inc/lib/Twig/Node/AutoEscape.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents an autoescape node.
- *
- * The value is the escaping strategy (can be html, js, ...)
- *
- * The true value is equivalent to html.
- *
- * If autoescaping is disabled, then the value is false.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_AutoEscape extends Twig_Node
-{
- public function __construct($value, Twig_NodeInterface $body, $lineno, $tag = 'autoescape')
- {
- parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->subcompile($this->getNode('body'));
- }
-}
-
-class_alias('Twig_Node_AutoEscape', 'Twig\Node\AutoEscapeNode', false);
diff --git a/inc/lib/Twig/Node/Block.php b/inc/lib/Twig/Node/Block.php
deleted file mode 100644
index 91752ad2..00000000
--- a/inc/lib/Twig/Node/Block.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a block node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Block extends Twig_Node
-{
- public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null)
- {
- parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n")
- ->indent()
- ;
-
- $compiler
- ->subcompile($this->getNode('body'))
- ->outdent()
- ->write("}\n\n")
- ;
- }
-}
-
-class_alias('Twig_Node_Block', 'Twig\Node\BlockNode', false);
diff --git a/inc/lib/Twig/Node/BlockReference.php b/inc/lib/Twig/Node/BlockReference.php
deleted file mode 100644
index 92a9f398..00000000
--- a/inc/lib/Twig/Node/BlockReference.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a block call node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInterface
-{
- public function __construct($name, $lineno, $tag = null)
- {
- parent::__construct(array(), array('name' => $name), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name')))
- ;
- }
-}
-
-class_alias('Twig_Node_BlockReference', 'Twig\Node\BlockReferenceNode', false);
diff --git a/inc/lib/Twig/Node/Body.php b/inc/lib/Twig/Node/Body.php
deleted file mode 100644
index 07dfef8b..00000000
--- a/inc/lib/Twig/Node/Body.php
+++ /dev/null
@@ -1,21 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a body node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Body extends Twig_Node
-{
-}
-
-class_alias('Twig_Node_Body', 'Twig\Node\BodyNode', false);
diff --git a/inc/lib/Twig/Node/CheckSecurity.php b/inc/lib/Twig/Node/CheckSecurity.php
deleted file mode 100644
index 7258acb6..00000000
--- a/inc/lib/Twig/Node/CheckSecurity.php
+++ /dev/null
@@ -1,80 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_CheckSecurity extends Twig_Node
-{
- protected $usedFilters;
- protected $usedTags;
- protected $usedFunctions;
-
- public function __construct(array $usedFilters, array $usedTags, array $usedFunctions)
- {
- $this->usedFilters = $usedFilters;
- $this->usedTags = $usedTags;
- $this->usedFunctions = $usedFunctions;
-
- parent::__construct();
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $tags = $filters = $functions = array();
- foreach (array('tags', 'filters', 'functions') as $type) {
- foreach ($this->{'used'.ucfirst($type)} as $name => $node) {
- if ($node instanceof Twig_Node) {
- ${$type}[$name] = $node->getTemplateLine();
- } else {
- ${$type}[$node] = null;
- }
- }
- }
-
- $compiler
- ->write('$tags = ')->repr(array_filter($tags))->raw(";\n")
- ->write('$filters = ')->repr(array_filter($filters))->raw(";\n")
- ->write('$functions = ')->repr(array_filter($functions))->raw(";\n\n")
- ->write("try {\n")
- ->indent()
- ->write("\$this->env->getExtension('Twig_Extension_Sandbox')->checkSecurity(\n")
- ->indent()
- ->write(!$tags ? "array(),\n" : "array('".implode("', '", array_keys($tags))."'),\n")
- ->write(!$filters ? "array(),\n" : "array('".implode("', '", array_keys($filters))."'),\n")
- ->write(!$functions ? "array()\n" : "array('".implode("', '", array_keys($functions))."')\n")
- ->outdent()
- ->write(");\n")
- ->outdent()
- ->write("} catch (Twig_Sandbox_SecurityError \$e) {\n")
- ->indent()
- ->write("\$e->setSourceContext(\$this->getSourceContext());\n\n")
- ->write("if (\$e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {\n")
- ->indent()
- ->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n")
- ->outdent()
- ->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset(\$filters[\$e->getFilterName()])) {\n")
- ->indent()
- ->write("\$e->setTemplateLine(\$filters[\$e->getFilterName()]);\n")
- ->outdent()
- ->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset(\$functions[\$e->getFunctionName()])) {\n")
- ->indent()
- ->write("\$e->setTemplateLine(\$functions[\$e->getFunctionName()]);\n")
- ->outdent()
- ->write("}\n\n")
- ->write("throw \$e;\n")
- ->outdent()
- ->write("}\n\n")
- ;
- }
-}
-
-class_alias('Twig_Node_CheckSecurity', 'Twig\Node\CheckSecurityNode', false);
diff --git a/inc/lib/Twig/Node/Do.php b/inc/lib/Twig/Node/Do.php
deleted file mode 100644
index cdd7e77a..00000000
--- a/inc/lib/Twig/Node/Do.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a do node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Do extends Twig_Node
-{
- public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
- {
- parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write('')
- ->subcompile($this->getNode('expr'))
- ->raw(";\n")
- ;
- }
-}
-
-class_alias('Twig_Node_Do', 'Twig\Node\DoNode', false);
diff --git a/inc/lib/Twig/Node/Embed.php b/inc/lib/Twig/Node/Embed.php
deleted file mode 100644
index 3785d3a9..00000000
--- a/inc/lib/Twig/Node/Embed.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents an embed node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Embed extends Twig_Node_Include
-{
- // we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
- public function __construct($name, $index, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
- {
- parent::__construct(new Twig_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag);
-
- $this->setAttribute('name', $name);
- // to be removed in 2.0, used name instead
- $this->setAttribute('filename', $name);
- $this->setAttribute('index', $index);
- }
-
- protected function addGetTemplate(Twig_Compiler $compiler)
- {
- $compiler
- ->write('$this->loadTemplate(')
- ->string($this->getAttribute('name'))
- ->raw(', ')
- ->repr($this->getTemplateName())
- ->raw(', ')
- ->repr($this->getTemplateLine())
- ->raw(', ')
- ->string($this->getAttribute('index'))
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Embed', 'Twig\Node\EmbedNode', false);
diff --git a/inc/lib/Twig/Node/Expression.php b/inc/lib/Twig/Node/Expression.php
deleted file mode 100644
index a99c4e63..00000000
--- a/inc/lib/Twig/Node/Expression.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Abstract class for all nodes that represents an expression.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-abstract class Twig_Node_Expression extends Twig_Node
-{
-}
-
-class_alias('Twig_Node_Expression', 'Twig\Node\Expression\AbstractExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/Array.php b/inc/lib/Twig/Node/Expression/Array.php
deleted file mode 100644
index 0e77bb08..00000000
--- a/inc/lib/Twig/Node/Expression/Array.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Array extends Twig_Node_Expression
-{
- protected $index;
-
- public function __construct(array $elements, $lineno)
- {
- parent::__construct($elements, array(), $lineno);
-
- $this->index = -1;
- foreach ($this->getKeyValuePairs() as $pair) {
- if ($pair['key'] instanceof Twig_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) {
- $this->index = $pair['key']->getAttribute('value');
- }
- }
- }
-
- public function getKeyValuePairs()
- {
- $pairs = array();
-
- foreach (array_chunk($this->nodes, 2) as $pair) {
- $pairs[] = array(
- 'key' => $pair[0],
- 'value' => $pair[1],
- );
- }
-
- return $pairs;
- }
-
- public function hasElement(Twig_Node_Expression $key)
- {
- foreach ($this->getKeyValuePairs() as $pair) {
- // we compare the string representation of the keys
- // to avoid comparing the line numbers which are not relevant here.
- if ((string) $key === (string) $pair['key']) {
- return true;
- }
- }
-
- return false;
- }
-
- public function addElement(Twig_Node_Expression $value, Twig_Node_Expression $key = null)
- {
- if (null === $key) {
- $key = new Twig_Node_Expression_Constant(++$this->index, $value->getTemplateLine());
- }
-
- array_push($this->nodes, $key, $value);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->raw('array(');
- $first = true;
- foreach ($this->getKeyValuePairs() as $pair) {
- if (!$first) {
- $compiler->raw(', ');
- }
- $first = false;
-
- $compiler
- ->subcompile($pair['key'])
- ->raw(' => ')
- ->subcompile($pair['value'])
- ;
- }
- $compiler->raw(')');
- }
-}
-
-class_alias('Twig_Node_Expression_Array', 'Twig\Node\Expression\ArrayExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/AssignName.php b/inc/lib/Twig/Node/Expression/AssignName.php
deleted file mode 100644
index 2e6b4c7c..00000000
--- a/inc/lib/Twig/Node/Expression/AssignName.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-class Twig_Node_Expression_AssignName extends Twig_Node_Expression_Name
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('$context[')
- ->string($this->getAttribute('name'))
- ->raw(']')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_AssignName', 'Twig\Node\Expression\AssignNameExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary.php b/inc/lib/Twig/Node/Expression/Binary.php
deleted file mode 100644
index 2b545d98..00000000
--- a/inc/lib/Twig/Node/Expression/Binary.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression
-{
- public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno)
- {
- parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(')
- ->subcompile($this->getNode('left'))
- ->raw(' ')
- ;
- $this->operator($compiler);
- $compiler
- ->raw(' ')
- ->subcompile($this->getNode('right'))
- ->raw(')')
- ;
- }
-
- abstract public function operator(Twig_Compiler $compiler);
-}
-
-class_alias('Twig_Node_Expression_Binary', 'Twig\Node\Expression\Binary\AbstractBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Add.php b/inc/lib/Twig/Node/Expression/Binary/Add.php
deleted file mode 100644
index 5a09d836..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Add.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Add extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('+');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Add', 'Twig\Node\Expression\Binary\AddBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/And.php b/inc/lib/Twig/Node/Expression/Binary/And.php
deleted file mode 100644
index 9ffddce6..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/And.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_And extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('&&');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_And', 'Twig\Node\Expression\Binary\AndBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/BitwiseAnd.php b/inc/lib/Twig/Node/Expression/Binary/BitwiseAnd.php
deleted file mode 100644
index e46e9ebf..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/BitwiseAnd.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_BitwiseAnd extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('&');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_BitwiseAnd', 'Twig\Node\Expression\Binary\BitwiseAndBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/BitwiseOr.php b/inc/lib/Twig/Node/Expression/Binary/BitwiseOr.php
deleted file mode 100644
index 5d7f1b7c..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/BitwiseOr.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_BitwiseOr extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('|');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_BitwiseOr', 'Twig\Node\Expression\Binary\BitwiseOrBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/BitwiseXor.php b/inc/lib/Twig/Node/Expression/Binary/BitwiseXor.php
deleted file mode 100644
index 82edf516..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/BitwiseXor.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_BitwiseXor extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('^');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_BitwiseXor', 'Twig\Node\Expression\Binary\BitwiseXorBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Concat.php b/inc/lib/Twig/Node/Expression/Binary/Concat.php
deleted file mode 100644
index 91abca60..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Concat.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Concat extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('.');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Concat', 'Twig\Node\Expression\Binary\ConcatBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Div.php b/inc/lib/Twig/Node/Expression/Binary/Div.php
deleted file mode 100644
index 38ffa30c..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Div.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Div extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('/');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Div', 'Twig\Node\Expression\Binary\DivBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/EndsWith.php b/inc/lib/Twig/Node/Expression/Binary/EndsWith.php
deleted file mode 100644
index 85c52937..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/EndsWith.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_EndsWith extends Twig_Node_Expression_Binary
-{
- public function compile(Twig_Compiler $compiler)
- {
- $left = $compiler->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);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Equal.php b/inc/lib/Twig/Node/Expression/Binary/Equal.php
deleted file mode 100644
index a6a6946b..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Equal.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Equal extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('==');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Equal', 'Twig\Node\Expression\Binary\EqualBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/FloorDiv.php b/inc/lib/Twig/Node/Expression/Binary/FloorDiv.php
deleted file mode 100644
index 7393bcb8..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/FloorDiv.php
+++ /dev/null
@@ -1,26 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_FloorDiv extends Twig_Node_Expression_Binary
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->raw('(int) floor(');
- parent::compile($compiler);
- $compiler->raw(')');
- }
-
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('/');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_FloorDiv', 'Twig\Node\Expression\Binary\FloorDivBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Greater.php b/inc/lib/Twig/Node/Expression/Binary/Greater.php
deleted file mode 100644
index 832f9797..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Greater.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Greater extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('>');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Greater', 'Twig\Node\Expression\Binary\GreaterBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/GreaterEqual.php b/inc/lib/Twig/Node/Expression/Binary/GreaterEqual.php
deleted file mode 100644
index c5f76245..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/GreaterEqual.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_GreaterEqual extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('>=');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_GreaterEqual', 'Twig\Node\Expression\Binary\GreaterEqualBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/In.php b/inc/lib/Twig/Node/Expression/Binary/In.php
deleted file mode 100644
index af112448..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/In.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_In extends Twig_Node_Expression_Binary
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('twig_in_filter(')
- ->subcompile($this->getNode('left'))
- ->raw(', ')
- ->subcompile($this->getNode('right'))
- ->raw(')')
- ;
- }
-
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('in');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_In', 'Twig\Node\Expression\Binary\InBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Less.php b/inc/lib/Twig/Node/Expression/Binary/Less.php
deleted file mode 100644
index ab8fc1f9..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Less.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Less extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('<');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Less', 'Twig\Node\Expression\Binary\LessBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/LessEqual.php b/inc/lib/Twig/Node/Expression/Binary/LessEqual.php
deleted file mode 100644
index 71a279e9..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/LessEqual.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_LessEqual extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('<=');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_LessEqual', 'Twig\Node\Expression\Binary\LessEqualBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Matches.php b/inc/lib/Twig/Node/Expression/Binary/Matches.php
deleted file mode 100644
index 5cb85584..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Matches.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Matches extends Twig_Node_Expression_Binary
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('preg_match(')
- ->subcompile($this->getNode('right'))
- ->raw(', ')
- ->subcompile($this->getNode('left'))
- ->raw(')')
- ;
- }
-
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Matches', 'Twig\Node\Expression\Binary\MatchesBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Mod.php b/inc/lib/Twig/Node/Expression/Binary/Mod.php
deleted file mode 100644
index 28109633..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Mod.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Mod extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('%');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Mod', 'Twig\Node\Expression\Binary\ModBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Mul.php b/inc/lib/Twig/Node/Expression/Binary/Mul.php
deleted file mode 100644
index 790c6a22..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Mul.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Mul extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('*');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Mul', 'Twig\Node\Expression\Binary\MulBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/NotEqual.php b/inc/lib/Twig/Node/Expression/Binary/NotEqual.php
deleted file mode 100644
index bb45c9ed..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/NotEqual.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_NotEqual extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('!=');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_NotEqual', 'Twig\Node\Expression\Binary\NotEqualBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/NotIn.php b/inc/lib/Twig/Node/Expression/Binary/NotIn.php
deleted file mode 100644
index 9dedf92f..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/NotIn.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_NotIn extends Twig_Node_Expression_Binary
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('!twig_in_filter(')
- ->subcompile($this->getNode('left'))
- ->raw(', ')
- ->subcompile($this->getNode('right'))
- ->raw(')')
- ;
- }
-
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('not in');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_NotIn', 'Twig\Node\Expression\Binary\NotInBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Or.php b/inc/lib/Twig/Node/Expression/Binary/Or.php
deleted file mode 100644
index dc9eece1..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Or.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Or extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('||');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Or', 'Twig\Node\Expression\Binary\OrBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Power.php b/inc/lib/Twig/Node/Expression/Binary/Power.php
deleted file mode 100644
index d24777bd..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Power.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Power extends Twig_Node_Expression_Binary
-{
- public function compile(Twig_Compiler $compiler)
- {
- if (PHP_VERSION_ID >= 50600) {
- return parent::compile($compiler);
- }
-
- $compiler
- ->raw('pow(')
- ->subcompile($this->getNode('left'))
- ->raw(', ')
- ->subcompile($this->getNode('right'))
- ->raw(')')
- ;
- }
-
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('**');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Power', 'Twig\Node\Expression\Binary\PowerBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Range.php b/inc/lib/Twig/Node/Expression/Binary/Range.php
deleted file mode 100644
index 187f6765..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Range.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Range extends Twig_Node_Expression_Binary
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('range(')
- ->subcompile($this->getNode('left'))
- ->raw(', ')
- ->subcompile($this->getNode('right'))
- ->raw(')')
- ;
- }
-
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('..');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Range', 'Twig\Node\Expression\Binary\RangeBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/StartsWith.php b/inc/lib/Twig/Node/Expression/Binary/StartsWith.php
deleted file mode 100644
index 7e43b8de..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/StartsWith.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_StartsWith extends Twig_Node_Expression_Binary
-{
- public function compile(Twig_Compiler $compiler)
- {
- $left = $compiler->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 || 0 === strpos($%1$s, $%2$s)))', $left, $right))
- ;
- }
-
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_StartsWith', 'Twig\Node\Expression\Binary\StartsWithBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/Binary/Sub.php b/inc/lib/Twig/Node/Expression/Binary/Sub.php
deleted file mode 100644
index cff8ed07..00000000
--- a/inc/lib/Twig/Node/Expression/Binary/Sub.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Binary_Sub extends Twig_Node_Expression_Binary
-{
- public function operator(Twig_Compiler $compiler)
- {
- return $compiler->raw('-');
- }
-}
-
-class_alias('Twig_Node_Expression_Binary_Sub', 'Twig\Node\Expression\Binary\SubBinary', false);
diff --git a/inc/lib/Twig/Node/Expression/BlockReference.php b/inc/lib/Twig/Node/Expression/BlockReference.php
deleted file mode 100644
index 37a3983d..00000000
--- a/inc/lib/Twig/Node/Expression/BlockReference.php
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a block call node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
-{
- /**
- * @param Twig_Node|null $template
- */
- public function __construct(Twig_NodeInterface $name, $template = null, $lineno, $tag = null)
- {
- if (is_bool($template)) {
- @trigger_error(sprintf('The %s method "$asString" argument is deprecated since version 1.28 and will be removed in 2.0.', __METHOD__), E_USER_DEPRECATED);
-
- $template = null;
- }
-
- $nodes = array('name' => $name);
- if (null !== $template) {
- $nodes['template'] = $template;
- }
-
- parent::__construct($nodes, array('is_defined_test' => false, 'output' => false), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- if ($this->getAttribute('is_defined_test')) {
- $this->compileTemplateCall($compiler, 'hasBlock');
- } else {
- if ($this->getAttribute('output')) {
- $compiler->addDebugInfo($this);
-
- $this
- ->compileTemplateCall($compiler, 'displayBlock')
- ->raw(";\n");
- } else {
- $this->compileTemplateCall($compiler, 'renderBlock');
- }
- }
- }
-
- private function compileTemplateCall(Twig_Compiler $compiler, $method)
- {
- if (!$this->hasNode('template')) {
- $compiler->write('$this');
- } else {
- $compiler
- ->write('$this->loadTemplate(')
- ->subcompile($this->getNode('template'))
- ->raw(', ')
- ->repr($this->getTemplateName())
- ->raw(', ')
- ->repr($this->getTemplateLine())
- ->raw(')')
- ;
- }
-
- $compiler->raw(sprintf('->%s', $method));
- $this->compileBlockArguments($compiler);
-
- return $compiler;
- }
-
- private function compileBlockArguments(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(')
- ->subcompile($this->getNode('name'))
- ->raw(', $context');
-
- if (!$this->hasNode('template')) {
- $compiler->raw(', $blocks');
- }
-
- return $compiler->raw(')');
- }
-}
-
-class_alias('Twig_Node_Expression_BlockReference', 'Twig\Node\Expression\BlockReferenceExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/Call.php b/inc/lib/Twig/Node/Expression/Call.php
deleted file mode 100644
index d962b6a5..00000000
--- a/inc/lib/Twig/Node/Expression/Call.php
+++ /dev/null
@@ -1,291 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
-{
- private $reflector;
-
- protected function compileCallable(Twig_Compiler $compiler)
- {
- $closingParenthesis = false;
- if ($this->hasAttribute('callable') && $callable = $this->getAttribute('callable')) {
- if (is_string($callable) && false === strpos($callable, '::')) {
- $compiler->raw($callable);
- } else {
- list($r, $callable) = $this->reflectCallable($callable);
- if ($r instanceof ReflectionMethod && is_string($callable[0])) {
- if ($r->isStatic()) {
- $compiler->raw(sprintf('%s::%s', $callable[0], $callable[1]));
- } else {
- $compiler->raw(sprintf('$this->env->getRuntime(\'%s\')->%s', $callable[0], $callable[1]));
- }
- } elseif ($r instanceof ReflectionMethod && $callable[0] instanceof Twig_ExtensionInterface) {
- $compiler->raw(sprintf('$this->env->getExtension(\'%s\')->%s', get_class($callable[0]), $callable[1]));
- } else {
- $type = ucfirst($this->getAttribute('type'));
- $compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), array', $type, $this->getAttribute('name')));
- $closingParenthesis = true;
- }
- }
- } else {
- $compiler->raw($this->getAttribute('thing')->compile());
- }
-
- $this->compileArguments($compiler);
-
- if ($closingParenthesis) {
- $compiler->raw(')');
- }
- }
-
- protected function compileArguments(Twig_Compiler $compiler)
- {
- $compiler->raw('(');
-
- $first = true;
-
- if ($this->hasAttribute('needs_environment') && $this->getAttribute('needs_environment')) {
- $compiler->raw('$this->env');
- $first = false;
- }
-
- if ($this->hasAttribute('needs_context') && $this->getAttribute('needs_context')) {
- if (!$first) {
- $compiler->raw(', ');
- }
- $compiler->raw('$context');
- $first = false;
- }
-
- if ($this->hasAttribute('arguments')) {
- foreach ($this->getAttribute('arguments') as $argument) {
- if (!$first) {
- $compiler->raw(', ');
- }
- $compiler->string($argument);
- $first = false;
- }
- }
-
- if ($this->hasNode('node')) {
- if (!$first) {
- $compiler->raw(', ');
- }
- $compiler->subcompile($this->getNode('node'));
- $first = false;
- }
-
- if ($this->hasNode('arguments')) {
- $callable = $this->hasAttribute('callable') ? $this->getAttribute('callable') : null;
-
- $arguments = $this->getArguments($callable, $this->getNode('arguments'));
-
- foreach ($arguments as $node) {
- if (!$first) {
- $compiler->raw(', ');
- }
- $compiler->subcompile($node);
- $first = false;
- }
- }
-
- $compiler->raw(')');
- }
-
- protected function getArguments($callable, $arguments)
- {
- $callType = $this->getAttribute('type');
- $callName = $this->getAttribute('name');
-
- $parameters = array();
- $named = false;
- foreach ($arguments as $name => $node) {
- if (!is_int($name)) {
- $named = true;
- $name = $this->normalizeName($name);
- } elseif ($named) {
- throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $callType, $callName));
- }
-
- $parameters[$name] = $node;
- }
-
- $isVariadic = $this->hasAttribute('is_variadic') && $this->getAttribute('is_variadic');
- if (!$named && !$isVariadic) {
- return $parameters;
- }
-
- if (!$callable) {
- if ($named) {
- $message = sprintf('Named arguments are not supported for %s "%s".', $callType, $callName);
- } else {
- $message = sprintf('Arbitrary positional arguments are not supported for %s "%s".', $callType, $callName);
- }
-
- throw new LogicException($message);
- }
-
- $callableParameters = $this->getCallableParameters($callable, $isVariadic);
- $arguments = array();
- $names = array();
- $missingArguments = array();
- $optionalArguments = array();
- $pos = 0;
- foreach ($callableParameters as $callableParameter) {
- $names[] = $name = $this->normalizeName($callableParameter->name);
-
- if (array_key_exists($name, $parameters)) {
- if (array_key_exists($pos, $parameters)) {
- throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $callType, $callName));
- }
-
- if (count($missingArguments)) {
- throw new Twig_Error_Syntax(sprintf(
- 'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".',
- $name, $callType, $callName, implode(', ', $names), count($missingArguments) > 1 ? 's' : '', implode('", "', $missingArguments))
- );
- }
-
- $arguments = array_merge($arguments, $optionalArguments);
- $arguments[] = $parameters[$name];
- unset($parameters[$name]);
- $optionalArguments = array();
- } elseif (array_key_exists($pos, $parameters)) {
- $arguments = array_merge($arguments, $optionalArguments);
- $arguments[] = $parameters[$pos];
- unset($parameters[$pos]);
- $optionalArguments = array();
- ++$pos;
- } elseif ($callableParameter->isDefaultValueAvailable()) {
- $optionalArguments[] = new Twig_Node_Expression_Constant($callableParameter->getDefaultValue(), -1);
- } elseif ($callableParameter->isOptional()) {
- if (empty($parameters)) {
- break;
- } else {
- $missingArguments[] = $name;
- }
- } else {
- throw new Twig_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $callType, $callName));
- }
- }
-
- if ($isVariadic) {
- $arbitraryArguments = new Twig_Node_Expression_Array(array(), -1);
- foreach ($parameters as $key => $value) {
- if (is_int($key)) {
- $arbitraryArguments->addElement($value);
- } else {
- $arbitraryArguments->addElement($value, new Twig_Node_Expression_Constant($key, -1));
- }
- unset($parameters[$key]);
- }
-
- if ($arbitraryArguments->count()) {
- $arguments = array_merge($arguments, $optionalArguments);
- $arguments[] = $arbitraryArguments;
- }
- }
-
- if (!empty($parameters)) {
- $unknownParameter = null;
- foreach ($parameters as $parameter) {
- if ($parameter instanceof Twig_Node) {
- $unknownParameter = $parameter;
- break;
- }
- }
-
- throw new Twig_Error_Syntax(sprintf(
- 'Unknown argument%s "%s" for %s "%s(%s)".',
- count($parameters) > 1 ? 's' : '', implode('", "', array_keys($parameters)), $callType, $callName, implode(', ', $names)
- ), $unknownParameter ? $unknownParameter->getTemplateLine() : -1);
- }
-
- return $arguments;
- }
-
- protected function normalizeName($name)
- {
- return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), $name));
- }
-
- private function getCallableParameters($callable, $isVariadic)
- {
- list($r) = $this->reflectCallable($callable);
- if (null === $r) {
- return array();
- }
-
- $parameters = $r->getParameters();
- if ($this->hasNode('node')) {
- array_shift($parameters);
- }
- if ($this->hasAttribute('needs_environment') && $this->getAttribute('needs_environment')) {
- array_shift($parameters);
- }
- if ($this->hasAttribute('needs_context') && $this->getAttribute('needs_context')) {
- array_shift($parameters);
- }
- if ($this->hasAttribute('arguments') && null !== $this->getAttribute('arguments')) {
- foreach ($this->getAttribute('arguments') as $argument) {
- array_shift($parameters);
- }
- }
- if ($isVariadic) {
- $argument = end($parameters);
- if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() && array() === $argument->getDefaultValue()) {
- array_pop($parameters);
- } else {
- $callableName = $r->name;
- if ($r instanceof ReflectionMethod) {
- $callableName = $r->getDeclaringClass()->name.'::'.$callableName;
- }
-
- throw new LogicException(sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = array()".', $callableName, $this->getAttribute('type'), $this->getAttribute('name')));
- }
- }
-
- return $parameters;
- }
-
- private function reflectCallable($callable)
- {
- if (null !== $this->reflector) {
- return $this->reflector;
- }
-
- if (is_array($callable)) {
- if (!method_exists($callable[0], $callable[1])) {
- // __call()
- return array(null, array());
- }
- $r = new ReflectionMethod($callable[0], $callable[1]);
- } elseif (is_object($callable) && !$callable instanceof Closure) {
- $r = new ReflectionObject($callable);
- $r = $r->getMethod('__invoke');
- $callable = array($callable, '__invoke');
- } elseif (is_string($callable) && false !== $pos = strpos($callable, '::')) {
- $class = substr($callable, 0, $pos);
- $method = substr($callable, $pos + 2);
- if (!method_exists($class, $method)) {
- // __staticCall()
- return array(null, array());
- }
- $r = new ReflectionMethod($callable);
- $callable = array($class, $method);
- } else {
- $r = new ReflectionFunction($callable);
- }
-
- return $this->reflector = array($r, $callable);
- }
-}
-
-class_alias('Twig_Node_Expression_Call', 'Twig\Node\Expression\CallExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/Conditional.php b/inc/lib/Twig/Node/Expression/Conditional.php
deleted file mode 100644
index c339d773..00000000
--- a/inc/lib/Twig/Node/Expression/Conditional.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Conditional extends Twig_Node_Expression
-{
- public function __construct(Twig_Node_Expression $expr1, Twig_Node_Expression $expr2, Twig_Node_Expression $expr3, $lineno)
- {
- parent::__construct(array('expr1' => $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('((')
- ->subcompile($this->getNode('expr1'))
- ->raw(') ? (')
- ->subcompile($this->getNode('expr2'))
- ->raw(') : (')
- ->subcompile($this->getNode('expr3'))
- ->raw('))')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Conditional', 'Twig\Node\Expression\ConditionalExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/Constant.php b/inc/lib/Twig/Node/Expression/Constant.php
deleted file mode 100644
index bf4d031c..00000000
--- a/inc/lib/Twig/Node/Expression/Constant.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Constant extends Twig_Node_Expression
-{
- public function __construct($value, $lineno)
- {
- parent::__construct(array(), array('value' => $value), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->repr($this->getAttribute('value'));
- }
-}
-
-class_alias('Twig_Node_Expression_Constant', 'Twig\Node\Expression\ConstantExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/ExtensionReference.php b/inc/lib/Twig/Node/Expression/ExtensionReference.php
deleted file mode 100644
index 114b5cd9..00000000
--- a/inc/lib/Twig/Node/Expression/ExtensionReference.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-@trigger_error('The Twig_Node_Expression_ExtensionReference class is deprecated since version 1.23 and will be removed in 2.0.', E_USER_DEPRECATED);
-
-/**
- * Represents an extension call node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- *
- * @deprecated since 1.23 and will be removed in 2.0.
- */
-class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression
-{
- public function __construct($name, $lineno, $tag = null)
- {
- parent::__construct(array(), array('name' => $name), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name')));
- }
-}
diff --git a/inc/lib/Twig/Node/Expression/Filter.php b/inc/lib/Twig/Node/Expression/Filter.php
deleted file mode 100644
index 12da1d67..00000000
--- a/inc/lib/Twig/Node/Expression/Filter.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Filter extends Twig_Node_Expression_Call
-{
- public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null)
- {
- parent::__construct(array('node' => $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $name = $this->getNode('filter')->getAttribute('value');
- $filter = $compiler->getEnvironment()->getFilter($name);
-
- $this->setAttribute('name', $name);
- $this->setAttribute('type', 'filter');
- $this->setAttribute('thing', $filter);
- $this->setAttribute('needs_environment', $filter->needsEnvironment());
- $this->setAttribute('needs_context', $filter->needsContext());
- $this->setAttribute('arguments', $filter->getArguments());
- if ($filter instanceof Twig_FilterCallableInterface || $filter instanceof Twig_SimpleFilter) {
- $this->setAttribute('callable', $filter->getCallable());
- }
- if ($filter instanceof Twig_SimpleFilter) {
- $this->setAttribute('is_variadic', $filter->isVariadic());
- }
-
- $this->compileCallable($compiler);
- }
-}
-
-class_alias('Twig_Node_Expression_Filter', 'Twig\Node\Expression\FilterExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/Filter/Default.php b/inc/lib/Twig/Node/Expression/Filter/Default.php
deleted file mode 100644
index d2e19d54..00000000
--- a/inc/lib/Twig/Node/Expression/Filter/Default.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Returns the value or the default value when it is undefined or empty.
- *
- * <pre>
- * {{ var.foo|default('foo item on var is not defined') }}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter
-{
- public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null)
- {
- $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('default', $node->getTemplateLine()), $arguments, $node->getTemplateLine());
-
- if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) {
- $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getTemplateLine());
- $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getTemplateLine());
-
- $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getTemplateLine());
- } else {
- $node = $default;
- }
-
- parent::__construct($node, $filterName, $arguments, $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->subcompile($this->getNode('node'));
- }
-}
-
-class_alias('Twig_Node_Expression_Filter_Default', 'Twig\Node\Expression\Filter\DefaultFilter', false);
diff --git a/inc/lib/Twig/Node/Expression/Function.php b/inc/lib/Twig/Node/Expression/Function.php
deleted file mode 100644
index cdee7c97..00000000
--- a/inc/lib/Twig/Node/Expression/Function.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Function extends Twig_Node_Expression_Call
-{
- public function __construct($name, Twig_NodeInterface $arguments, $lineno)
- {
- parent::__construct(array('arguments' => $arguments), array('name' => $name, 'is_defined_test' => false), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $name = $this->getAttribute('name');
- $function = $compiler->getEnvironment()->getFunction($name);
-
- $this->setAttribute('name', $name);
- $this->setAttribute('type', 'function');
- $this->setAttribute('thing', $function);
- $this->setAttribute('needs_environment', $function->needsEnvironment());
- $this->setAttribute('needs_context', $function->needsContext());
- $this->setAttribute('arguments', $function->getArguments());
- if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) {
- $callable = $function->getCallable();
- if ('constant' === $name && $this->getAttribute('is_defined_test')) {
- $callable = 'twig_constant_is_defined';
- }
-
- $this->setAttribute('callable', $callable);
- }
- if ($function instanceof Twig_SimpleFunction) {
- $this->setAttribute('is_variadic', $function->isVariadic());
- }
-
- $this->compileCallable($compiler);
- }
-}
-
-class_alias('Twig_Node_Expression_Function', 'Twig\Node\Expression\FunctionExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/GetAttr.php b/inc/lib/Twig/Node/Expression/GetAttr.php
deleted file mode 100644
index b7823acc..00000000
--- a/inc/lib/Twig/Node/Expression/GetAttr.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_GetAttr extends Twig_Node_Expression
-{
- public function __construct(Twig_Node_Expression $node, Twig_Node_Expression $attribute, Twig_Node_Expression $arguments = null, $type, $lineno)
- {
- $nodes = array('node' => $node, 'attribute' => $attribute);
- if (null !== $arguments) {
- $nodes['arguments'] = $arguments;
- }
-
- parent::__construct($nodes, array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- if ($this->getAttribute('disable_c_ext')) {
- @trigger_error(sprintf('Using the "disable_c_ext" attribute on %s is deprecated since version 1.30 and will be removed in 2.0.', __CLASS__), E_USER_DEPRECATED);
- }
-
- if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) {
- $compiler->raw('twig_template_get_attributes($this, ');
- } else {
- $compiler->raw('$this->getAttribute(');
- }
-
- if ($this->getAttribute('ignore_strict_check')) {
- $this->getNode('node')->setAttribute('ignore_strict_check', true);
- }
-
- $compiler->subcompile($this->getNode('node'));
-
- $compiler->raw(', ')->subcompile($this->getNode('attribute'));
-
- // only generate optional arguments when needed (to make generated code more readable)
- $needFourth = $this->getAttribute('ignore_strict_check');
- $needThird = $needFourth || $this->getAttribute('is_defined_test');
- $needSecond = $needThird || Twig_Template::ANY_CALL !== $this->getAttribute('type');
- $needFirst = $needSecond || $this->hasNode('arguments');
-
- if ($needFirst) {
- if ($this->hasNode('arguments')) {
- $compiler->raw(', ')->subcompile($this->getNode('arguments'));
- } else {
- $compiler->raw(', array()');
- }
- }
-
- if ($needSecond) {
- $compiler->raw(', ')->repr($this->getAttribute('type'));
- }
-
- if ($needThird) {
- $compiler->raw(', ')->repr($this->getAttribute('is_defined_test'));
- }
-
- if ($needFourth) {
- $compiler->raw(', ')->repr($this->getAttribute('ignore_strict_check'));
- }
-
- $compiler->raw(')');
- }
-}
-
-class_alias('Twig_Node_Expression_GetAttr', 'Twig\Node\Expression\GetAttrExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/MacroCall.php b/inc/lib/Twig/Node/Expression/MacroCall.php
deleted file mode 100644
index 3e6b8c12..00000000
--- a/inc/lib/Twig/Node/Expression/MacroCall.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) 2012 Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a macro call node.
- *
- * @author Martin Hasoň <martin.hason@gmail.com>
- */
-class Twig_Node_Expression_MacroCall extends Twig_Node_Expression
-{
- public function __construct(Twig_Node_Expression $template, $name, Twig_Node_Expression_Array $arguments, $lineno)
- {
- parent::__construct(array('template' => $template, 'arguments' => $arguments), array('name' => $name), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $namedNames = array();
- $namedCount = 0;
- $positionalCount = 0;
- foreach ($this->getNode('arguments')->getKeyValuePairs() as $pair) {
- $name = $pair['key']->getAttribute('value');
- if (!is_int($name)) {
- $namedCount++;
- $namedNames[$name] = 1;
- } elseif ($namedCount > 0) {
- throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for macro "%s".', $this->getAttribute('name')), $this->lineno);
- } else {
- $positionalCount++;
- }
- }
-
- $compiler
- ->raw('$this->callMacro(')
- ->subcompile($this->getNode('template'))
- ->raw(', ')->repr($this->getAttribute('name'))
- ->raw(', ')->subcompile($this->getNode('arguments'))
- ;
-
- if ($namedCount > 0) {
- $compiler
- ->raw(', ')->repr($namedNames)
- ->raw(', ')->repr($namedCount)
- ->raw(', ')->repr($positionalCount)
- ;
- }
-
- $compiler
- ->raw(')')
- ;
- }
-}
diff --git a/inc/lib/Twig/Node/Expression/MethodCall.php b/inc/lib/Twig/Node/Expression/MethodCall.php
deleted file mode 100644
index 709016eb..00000000
--- a/inc/lib/Twig/Node/Expression/MethodCall.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_MethodCall extends Twig_Node_Expression
-{
- public function __construct(Twig_Node_Expression $node, $method, Twig_Node_Expression_Array $arguments, $lineno)
- {
- parent::__construct(array('node' => $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno);
-
- if ($node instanceof Twig_Node_Expression_Name) {
- $node->setAttribute('always_defined', true);
- }
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->subcompile($this->getNode('node'))
- ->raw('->')
- ->raw($this->getAttribute('method'))
- ->raw('(')
- ;
- $first = true;
- foreach ($this->getNode('arguments')->getKeyValuePairs() as $pair) {
- if (!$first) {
- $compiler->raw(', ');
- }
- $first = false;
-
- $compiler->subcompile($pair['value']);
- }
- $compiler->raw(')');
- }
-}
-
-class_alias('Twig_Node_Expression_MethodCall', 'Twig\Node\Expression\MethodCallExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/Name.php b/inc/lib/Twig/Node/Expression/Name.php
deleted file mode 100644
index 9d5a21f8..00000000
--- a/inc/lib/Twig/Node/Expression/Name.php
+++ /dev/null
@@ -1,102 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Name extends Twig_Node_Expression
-{
- protected $specialVars = array(
- '_self' => '$this',
- '_context' => '$context',
- '_charset' => '$this->env->getCharset()',
- );
-
- public function __construct($name, $lineno)
- {
- parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $name = $this->getAttribute('name');
-
- $compiler->addDebugInfo($this);
-
- if ($this->getAttribute('is_defined_test')) {
- if ($this->isSpecial()) {
- $compiler->repr(true);
- } else {
- $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)');
- }
- } elseif ($this->isSpecial()) {
- $compiler->raw($this->specialVars[$name]);
- } elseif ($this->getAttribute('always_defined')) {
- $compiler
- ->raw('$context[')
- ->string($name)
- ->raw(']')
- ;
- } else {
- if (PHP_VERSION_ID >= 70000) {
- // use PHP 7 null coalescing operator
- $compiler
- ->raw('($context[')
- ->string($name)
- ->raw('] ?? ')
- ;
-
- if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) {
- $compiler->raw('null)');
- } else {
- $compiler->raw('$this->getContext($context, ')->string($name)->raw('))');
- }
- } elseif (PHP_VERSION_ID >= 50400) {
- // PHP 5.4 ternary operator performance was optimized
- $compiler
- ->raw('(isset($context[')
- ->string($name)
- ->raw(']) ? $context[')
- ->string($name)
- ->raw('] : ')
- ;
-
- if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) {
- $compiler->raw('null)');
- } else {
- $compiler->raw('$this->getContext($context, ')->string($name)->raw('))');
- }
- } else {
- $compiler
- ->raw('$this->getContext($context, ')
- ->string($name)
- ;
-
- if ($this->getAttribute('ignore_strict_check')) {
- $compiler->raw(', true');
- }
-
- $compiler
- ->raw(')')
- ;
- }
- }
- }
-
- public function isSpecial()
- {
- return isset($this->specialVars[$this->getAttribute('name')]);
- }
-
- public function isSimple()
- {
- return !$this->isSpecial() && !$this->getAttribute('is_defined_test');
- }
-}
-
-class_alias('Twig_Node_Expression_Name', 'Twig\Node\Expression\NameExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/NullCoalesce.php b/inc/lib/Twig/Node/Expression/NullCoalesce.php
deleted file mode 100644
index eaafa4c9..00000000
--- a/inc/lib/Twig/Node/Expression/NullCoalesce.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_NullCoalesce extends Twig_Node_Expression_Conditional
-{
- public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno)
- {
- $test = new Twig_Node_Expression_Binary_And(
- new Twig_Node_Expression_Test_Defined(clone $left, 'defined', new Twig_Node(), $left->getTemplateLine()),
- new Twig_Node_Expression_Unary_Not(new Twig_Node_Expression_Test_Null($left, 'null', new Twig_Node(), $left->getTemplateLine()), $left->getTemplateLine()),
- $left->getTemplateLine()
- );
-
- parent::__construct($test, $left, $right, $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- /*
- * This optimizes only one case. PHP 7 also supports more complex expressions
- * that can return null. So, for instance, if log is defined, log("foo") ?? "..." works,
- * but log($a["foo"]) ?? "..." does not if $a["foo"] is not defined. More advanced
- * cases might be implemented as an optimizer node visitor, but has not been done
- * as benefits are probably not worth the added complexity.
- */
- if (PHP_VERSION_ID >= 70000 && $this->getNode('expr2') instanceof Twig_Node_Expression_Name) {
- $this->getNode('expr2')->setAttribute('always_defined', true);
- $compiler
- ->raw('((')
- ->subcompile($this->getNode('expr2'))
- ->raw(') ?? (')
- ->subcompile($this->getNode('expr3'))
- ->raw('))')
- ;
- } else {
- parent::compile($compiler);
- }
- }
-}
-
-class_alias('Twig_Node_Expression_NullCoalesce', 'Twig\Node\Expression\NullCoalesceExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/Parent.php b/inc/lib/Twig/Node/Expression/Parent.php
deleted file mode 100644
index 78692db2..00000000
--- a/inc/lib/Twig/Node/Expression/Parent.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a parent node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Parent extends Twig_Node_Expression
-{
- public function __construct($name, $lineno, $tag = null)
- {
- parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- if ($this->getAttribute('output')) {
- $compiler
- ->addDebugInfo($this)
- ->write('$this->displayParentBlock(')
- ->string($this->getAttribute('name'))
- ->raw(", \$context, \$blocks);\n")
- ;
- } else {
- $compiler
- ->raw('$this->renderParentBlock(')
- ->string($this->getAttribute('name'))
- ->raw(', $context, $blocks)')
- ;
- }
- }
-}
-
-class_alias('Twig_Node_Expression_Parent', 'Twig\Node\Expression\ParentExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/TempName.php b/inc/lib/Twig/Node/Expression/TempName.php
deleted file mode 100644
index 0a86e003..00000000
--- a/inc/lib/Twig/Node/Expression/TempName.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_TempName extends Twig_Node_Expression
-{
- public function __construct($name, $lineno)
- {
- parent::__construct(array(), array('name' => $name), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('$_')
- ->raw($this->getAttribute('name'))
- ->raw('_')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_TempName', 'Twig\Node\Expression\TempNameExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/Test.php b/inc/lib/Twig/Node/Expression/Test.php
deleted file mode 100644
index ad102ba6..00000000
--- a/inc/lib/Twig/Node/Expression/Test.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Test extends Twig_Node_Expression_Call
-{
- public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
- {
- $nodes = array('node' => $node);
- if (null !== $arguments) {
- $nodes['arguments'] = $arguments;
- }
-
- parent::__construct($nodes, array('name' => $name), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $name = $this->getAttribute('name');
- $test = $compiler->getEnvironment()->getTest($name);
-
- $this->setAttribute('name', $name);
- $this->setAttribute('type', 'test');
- $this->setAttribute('thing', $test);
- if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) {
- $this->setAttribute('callable', $test->getCallable());
- }
- if ($test instanceof Twig_SimpleTest) {
- $this->setAttribute('is_variadic', $test->isVariadic());
- }
-
- $this->compileCallable($compiler);
- }
-}
-
-class_alias('Twig_Node_Expression_Test', 'Twig\Node\Expression\TestExpression', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Constant.php b/inc/lib/Twig/Node/Expression/Test/Constant.php
deleted file mode 100644
index a51a4ba1..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Constant.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a variable is the exact same value as a constant.
- *
- * <pre>
- * {% if post.status is constant('Post::PUBLISHED') %}
- * the status attribute is exactly the same as Post::PUBLISHED
- * {% endif %}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(')
- ->subcompile($this->getNode('node'))
- ->raw(' === constant(')
- ;
-
- if ($this->getNode('arguments')->hasNode(1)) {
- $compiler
- ->raw('get_class(')
- ->subcompile($this->getNode('arguments')->getNode(1))
- ->raw(')."::".')
- ;
- }
-
- $compiler
- ->subcompile($this->getNode('arguments')->getNode(0))
- ->raw('))')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Constant', 'Twig\Node\Expression\Test\ConstantTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Defined.php b/inc/lib/Twig/Node/Expression/Test/Defined.php
deleted file mode 100644
index 2136c390..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Defined.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a variable is defined in the current context.
- *
- * <pre>
- * {# defined works with variable names and variable attributes #}
- * {% if foo is defined %}
- * {# ... #}
- * {% endif %}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test
-{
- public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
- {
- if ($node instanceof Twig_Node_Expression_Name) {
- $node->setAttribute('is_defined_test', true);
- } elseif ($node instanceof Twig_Node_Expression_GetAttr) {
- $node->setAttribute('is_defined_test', true);
- $this->changeIgnoreStrictCheck($node);
- } elseif ($node instanceof Twig_Node_Expression_BlockReference) {
- $node->setAttribute('is_defined_test', true);
- } elseif ($node instanceof Twig_Node_Expression_Function && 'constant' === $node->getAttribute('name')) {
- $node->setAttribute('is_defined_test', true);
- } elseif ($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array) {
- $node = new Twig_Node_Expression_Constant(true, $node->getTemplateLine());
- } else {
- throw new Twig_Error_Syntax('The "defined" test only works with simple variables.', $this->getTemplateLine());
- }
-
- parent::__construct($node, $name, $arguments, $lineno);
- }
-
- protected function changeIgnoreStrictCheck(Twig_Node_Expression_GetAttr $node)
- {
- $node->setAttribute('ignore_strict_check', true);
-
- if ($node->getNode('node') instanceof Twig_Node_Expression_GetAttr) {
- $this->changeIgnoreStrictCheck($node->getNode('node'));
- }
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->subcompile($this->getNode('node'));
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Defined', 'Twig\Node\Expression\Test\DefinedTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Divisibleby.php b/inc/lib/Twig/Node/Expression/Test/Divisibleby.php
deleted file mode 100644
index a5d71961..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Divisibleby.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a variable is divisible by a number.
- *
- * <pre>
- * {% if loop.index is divisible by(3) %}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(0 == ')
- ->subcompile($this->getNode('node'))
- ->raw(' % ')
- ->subcompile($this->getNode('arguments')->getNode(0))
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Divisibleby', 'Twig\Node\Expression\Test\DivisiblebyTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Even.php b/inc/lib/Twig/Node/Expression/Test/Even.php
deleted file mode 100644
index 7e198bea..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Even.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a number is even.
- *
- * <pre>
- * {{ var is even }}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(')
- ->subcompile($this->getNode('node'))
- ->raw(' % 2 == 0')
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Even', 'Twig\Node\Expression\Test\EvenTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Null.php b/inc/lib/Twig/Node/Expression/Test/Null.php
deleted file mode 100644
index 3746e4cb..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Null.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks that a variable is null.
- *
- * <pre>
- * {{ var is none }}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(null === ')
- ->subcompile($this->getNode('node'))
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Null', 'Twig\Node\Expression\Test\NullTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Odd.php b/inc/lib/Twig/Node/Expression/Test/Odd.php
deleted file mode 100644
index 0c6c099b..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Odd.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a number is odd.
- *
- * <pre>
- * {{ var is odd }}
- * </pre>
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(')
- ->subcompile($this->getNode('node'))
- ->raw(' % 2 == 1')
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Odd', 'Twig\Node\Expression\Test\OddTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Test/Sameas.php b/inc/lib/Twig/Node/Expression/Test/Sameas.php
deleted file mode 100644
index e95ff1f2..00000000
--- a/inc/lib/Twig/Node/Expression/Test/Sameas.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Checks if a variable is the same as another one (=== in PHP).
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->raw('(')
- ->subcompile($this->getNode('node'))
- ->raw(' === ')
- ->subcompile($this->getNode('arguments')->getNode(0))
- ->raw(')')
- ;
- }
-}
-
-class_alias('Twig_Node_Expression_Test_Sameas', 'Twig\Node\Expression\Test\SameasTest', false);
diff --git a/inc/lib/Twig/Node/Expression/Unary.php b/inc/lib/Twig/Node/Expression/Unary.php
deleted file mode 100644
index 5804485e..00000000
--- a/inc/lib/Twig/Node/Expression/Unary.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-abstract class Twig_Node_Expression_Unary extends Twig_Node_Expression
-{
- public function __construct(Twig_NodeInterface $node, $lineno)
- {
- parent::__construct(array('node' => $node), array(), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->raw(' ');
- $this->operator($compiler);
- $compiler->subcompile($this->getNode('node'));
- }
-
- abstract public function operator(Twig_Compiler $compiler);
-}
-
-class_alias('Twig_Node_Expression_Unary', 'Twig\Node\Expression\Unary\AbstractUnary', false);
diff --git a/inc/lib/Twig/Node/Expression/Unary/Neg.php b/inc/lib/Twig/Node/Expression/Unary/Neg.php
deleted file mode 100644
index 039d933d..00000000
--- a/inc/lib/Twig/Node/Expression/Unary/Neg.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Unary_Neg extends Twig_Node_Expression_Unary
-{
- public function operator(Twig_Compiler $compiler)
- {
- $compiler->raw('-');
- }
-}
-
-class_alias('Twig_Node_Expression_Unary_Neg', 'Twig\Node\Expression\Unary\NegUnary', false);
diff --git a/inc/lib/Twig/Node/Expression/Unary/Not.php b/inc/lib/Twig/Node/Expression/Unary/Not.php
deleted file mode 100644
index a0860b18..00000000
--- a/inc/lib/Twig/Node/Expression/Unary/Not.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Unary_Not extends Twig_Node_Expression_Unary
-{
- public function operator(Twig_Compiler $compiler)
- {
- $compiler->raw('!');
- }
-}
-
-class_alias('Twig_Node_Expression_Unary_Not', 'Twig\Node\Expression\Unary\NotUnary', false);
diff --git a/inc/lib/Twig/Node/Expression/Unary/Pos.php b/inc/lib/Twig/Node/Expression/Unary/Pos.php
deleted file mode 100644
index eeff5452..00000000
--- a/inc/lib/Twig/Node/Expression/Unary/Pos.php
+++ /dev/null
@@ -1,20 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-class Twig_Node_Expression_Unary_Pos extends Twig_Node_Expression_Unary
-{
- public function operator(Twig_Compiler $compiler)
- {
- $compiler->raw('+');
- }
-}
-
-class_alias('Twig_Node_Expression_Unary_Pos', 'Twig\Node\Expression\Unary\PosUnary', false);
diff --git a/inc/lib/Twig/Node/Flush.php b/inc/lib/Twig/Node/Flush.php
deleted file mode 100644
index fcc461ac..00000000
--- a/inc/lib/Twig/Node/Flush.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a flush node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Flush extends Twig_Node
-{
- public function __construct($lineno, $tag)
- {
- parent::__construct(array(), array(), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write("flush();\n")
- ;
- }
-}
-
-class_alias('Twig_Node_Flush', 'Twig\Node\FlushNode', false);
diff --git a/inc/lib/Twig/Node/For.php b/inc/lib/Twig/Node/For.php
deleted file mode 100644
index 914b70c9..00000000
--- a/inc/lib/Twig/Node/For.php
+++ /dev/null
@@ -1,113 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a for node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_For extends Twig_Node
-{
- protected $loop;
-
- public function __construct(Twig_Node_Expression_AssignName $keyTarget, Twig_Node_Expression_AssignName $valueTarget, Twig_Node_Expression $seq, Twig_Node_Expression $ifexpr = null, Twig_NodeInterface $body, Twig_NodeInterface $else = null, $lineno, $tag = null)
- {
- $body = new Twig_Node(array($body, $this->loop = new Twig_Node_ForLoop($lineno, $tag)));
-
- if (null !== $ifexpr) {
- $body = new Twig_Node_If(new Twig_Node(array($ifexpr, $body)), null, $lineno, $tag);
- }
-
- $nodes = array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body);
- if (null !== $else) {
- $nodes['else'] = $else;
- }
-
- parent::__construct($nodes, array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write("\$context['_parent'] = \$context;\n")
- ->write("\$context['_seq'] = twig_ensure_traversable(")
- ->subcompile($this->getNode('seq'))
- ->raw(");\n")
- ;
-
- if ($this->hasNode('else')) {
- $compiler->write("\$context['_iterated'] = false;\n");
- }
-
- if ($this->getAttribute('with_loop')) {
- $compiler
- ->write("\$context['loop'] = array(\n")
- ->write(" 'parent' => \$context['_parent'],\n")
- ->write(" 'index0' => 0,\n")
- ->write(" 'index' => 1,\n")
- ->write(" 'first' => true,\n")
- ->write(");\n")
- ;
-
- if (!$this->getAttribute('ifexpr')) {
- $compiler
- ->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {\n")
- ->indent()
- ->write("\$length = count(\$context['_seq']);\n")
- ->write("\$context['loop']['revindex0'] = \$length - 1;\n")
- ->write("\$context['loop']['revindex'] = \$length;\n")
- ->write("\$context['loop']['length'] = \$length;\n")
- ->write("\$context['loop']['last'] = 1 === \$length;\n")
- ->outdent()
- ->write("}\n")
- ;
- }
- }
-
- $this->loop->setAttribute('else', $this->hasNode('else'));
- $this->loop->setAttribute('with_loop', $this->getAttribute('with_loop'));
- $this->loop->setAttribute('ifexpr', $this->getAttribute('ifexpr'));
-
- $compiler
- ->write("foreach (\$context['_seq'] as ")
- ->subcompile($this->getNode('key_target'))
- ->raw(' => ')
- ->subcompile($this->getNode('value_target'))
- ->raw(") {\n")
- ->indent()
- ->subcompile($this->getNode('body'))
- ->outdent()
- ->write("}\n")
- ;
-
- if ($this->hasNode('else')) {
- $compiler
- ->write("if (!\$context['_iterated']) {\n")
- ->indent()
- ->subcompile($this->getNode('else'))
- ->outdent()
- ->write("}\n")
- ;
- }
-
- $compiler->write("\$_parent = \$context['_parent'];\n");
-
- // remove some "private" loop variables (needed for nested loops)
- $compiler->write('unset($context[\'_seq\'], $context[\'_iterated\'], $context[\''.$this->getNode('key_target')->getAttribute('name').'\'], $context[\''.$this->getNode('value_target')->getAttribute('name').'\'], $context[\'_parent\'], $context[\'loop\']);'."\n");
-
- // keep the values set in the inner context for variables defined in the outer context
- $compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n");
- }
-}
-
-class_alias('Twig_Node_For', 'Twig\Node\ForNode', false);
diff --git a/inc/lib/Twig/Node/ForLoop.php b/inc/lib/Twig/Node/ForLoop.php
deleted file mode 100644
index 06477cf1..00000000
--- a/inc/lib/Twig/Node/ForLoop.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Internal node used by the for node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_ForLoop extends Twig_Node
-{
- public function __construct($lineno, $tag = null)
- {
- parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- if ($this->getAttribute('else')) {
- $compiler->write("\$context['_iterated'] = true;\n");
- }
-
- if ($this->getAttribute('with_loop')) {
- $compiler
- ->write("++\$context['loop']['index0'];\n")
- ->write("++\$context['loop']['index'];\n")
- ->write("\$context['loop']['first'] = false;\n")
- ;
-
- if (!$this->getAttribute('ifexpr')) {
- $compiler
- ->write("if (isset(\$context['loop']['length'])) {\n")
- ->indent()
- ->write("--\$context['loop']['revindex0'];\n")
- ->write("--\$context['loop']['revindex'];\n")
- ->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n")
- ->outdent()
- ->write("}\n")
- ;
- }
- }
- }
-}
-
-class_alias('Twig_Node_ForLoop', 'Twig\Node\ForLoopNode', false);
diff --git a/inc/lib/Twig/Node/If.php b/inc/lib/Twig/Node/If.php
deleted file mode 100644
index d82edec7..00000000
--- a/inc/lib/Twig/Node/If.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents an if node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_If extends Twig_Node
-{
- public function __construct(Twig_NodeInterface $tests, Twig_NodeInterface $else = null, $lineno, $tag = null)
- {
- $nodes = array('tests' => $tests);
- if (null !== $else) {
- $nodes['else'] = $else;
- }
-
- parent::__construct($nodes, array(), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->addDebugInfo($this);
- for ($i = 0, $count = count($this->getNode('tests')); $i < $count; $i += 2) {
- if ($i > 0) {
- $compiler
- ->outdent()
- ->write('} elseif (')
- ;
- } else {
- $compiler
- ->write('if (')
- ;
- }
-
- $compiler
- ->subcompile($this->getNode('tests')->getNode($i))
- ->raw(") {\n")
- ->indent()
- ->subcompile($this->getNode('tests')->getNode($i + 1))
- ;
- }
-
- if ($this->hasNode('else')) {
- $compiler
- ->outdent()
- ->write("} else {\n")
- ->indent()
- ->subcompile($this->getNode('else'))
- ;
- }
-
- $compiler
- ->outdent()
- ->write("}\n");
- }
-}
-
-class_alias('Twig_Node_If', 'Twig\Node\IfNode', false);
diff --git a/inc/lib/Twig/Node/Import.php b/inc/lib/Twig/Node/Import.php
deleted file mode 100644
index c77e320b..00000000
--- a/inc/lib/Twig/Node/Import.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents an import node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Import extends Twig_Node
-{
- public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $var, $lineno, $tag = null)
- {
- parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write('')
- ->subcompile($this->getNode('var'))
- ->raw(' = ')
- ;
-
- if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) {
- $compiler->raw('$this');
- } else {
- $compiler
- ->raw('$this->loadTemplate(')
- ->subcompile($this->getNode('expr'))
- ->raw(', ')
- ->repr($this->getTemplateName())
- ->raw(', ')
- ->repr($this->getTemplateLine())
- ->raw(')')
- ;
- }
-
- $compiler->raw(";\n");
- }
-}
-
-class_alias('Twig_Node_Import', 'Twig\Node\ImportNode', false);
diff --git a/inc/lib/Twig/Node/Include.php b/inc/lib/Twig/Node/Include.php
deleted file mode 100644
index 2a5114cb..00000000
--- a/inc/lib/Twig/Node/Include.php
+++ /dev/null
@@ -1,90 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents an include node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
-{
- public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
- {
- $nodes = array('expr' => $expr);
- if (null !== $variables) {
- $nodes['variables'] = $variables;
- }
-
- parent::__construct($nodes, array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->addDebugInfo($this);
-
- if ($this->getAttribute('ignore_missing')) {
- $compiler
- ->write("try {\n")
- ->indent()
- ;
- }
-
- $this->addGetTemplate($compiler);
-
- $compiler->raw('->display(');
-
- $this->addTemplateArguments($compiler);
-
- $compiler->raw(");\n");
-
- if ($this->getAttribute('ignore_missing')) {
- $compiler
- ->outdent()
- ->write("} catch (Twig_Error_Loader \$e) {\n")
- ->indent()
- ->write("// ignore missing template\n")
- ->outdent()
- ->write("}\n\n")
- ;
- }
- }
-
- protected function addGetTemplate(Twig_Compiler $compiler)
- {
- $compiler
- ->write('$this->loadTemplate(')
- ->subcompile($this->getNode('expr'))
- ->raw(', ')
- ->repr($this->getTemplateName())
- ->raw(', ')
- ->repr($this->getTemplateLine())
- ->raw(')')
- ;
- }
-
- protected function addTemplateArguments(Twig_Compiler $compiler)
- {
- if (!$this->hasNode('variables')) {
- $compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()');
- } elseif (false === $this->getAttribute('only')) {
- $compiler
- ->raw('array_merge($context, ')
- ->subcompile($this->getNode('variables'))
- ->raw(')')
- ;
- } else {
- $compiler->subcompile($this->getNode('variables'));
- }
- }
-}
-
-class_alias('Twig_Node_Include', 'Twig\Node\IncludeNode', false);
diff --git a/inc/lib/Twig/Node/Macro.php b/inc/lib/Twig/Node/Macro.php
deleted file mode 100644
index 3cf54977..00000000
--- a/inc/lib/Twig/Node/Macro.php
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a macro node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Macro extends Twig_Node
-{
- const VARARGS_NAME = 'varargs';
-
- public function __construct($name, Twig_NodeInterface $body, Twig_NodeInterface $arguments, $lineno, $tag = null)
- {
- foreach ($arguments as $argumentName => $argument) {
- if (self::VARARGS_NAME === $argumentName) {
- throw new Twig_Error_Syntax(sprintf('The argument "%s" in macro "%s" cannot be defined because the variable "%s" is reserved for arbitrary arguments.', self::VARARGS_NAME, $name, self::VARARGS_NAME), $argument->getTemplateLine());
- }
- }
-
- parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write(sprintf('public function get%s(', $this->getAttribute('name')))
- ;
-
- $count = count($this->getNode('arguments'));
- $pos = 0;
- foreach ($this->getNode('arguments') as $name => $default) {
- $compiler
- ->raw('$__'.$name.'__ = ')
- ->subcompile($default)
- ;
-
- if (++$pos < $count) {
- $compiler->raw(', ');
- }
- }
-
- if (PHP_VERSION_ID >= 50600) {
- if ($count) {
- $compiler->raw(', ');
- }
-
- $compiler->raw('...$__varargs__');
- }
-
- $compiler
- ->raw(")\n")
- ->write("{\n")
- ->indent()
- ;
-
- $compiler
- ->write("\$context = \$this->env->mergeGlobals(array(\n")
- ->indent()
- ;
-
- foreach ($this->getNode('arguments') as $name => $default) {
- $compiler
- ->write('')
- ->string($name)
- ->raw(' => $__'.$name.'__')
- ->raw(",\n")
- ;
- }
-
- $compiler
- ->write('')
- ->string(self::VARARGS_NAME)
- ->raw(' => ')
- ;
-
- if (PHP_VERSION_ID >= 50600) {
- $compiler->raw("\$__varargs__,\n");
- } else {
- $compiler
- ->raw('func_num_args() > ')
- ->repr($count)
- ->raw(' ? array_slice(func_get_args(), ')
- ->repr($count)
- ->raw(") : array(),\n")
- ;
- }
-
- $compiler
- ->outdent()
- ->write("));\n\n")
- ->write("\$blocks = array();\n\n")
- ->write("ob_start();\n")
- ->write("try {\n")
- ->indent()
- ->subcompile($this->getNode('body'))
- ->outdent()
- ->write("} catch (Exception \$e) {\n")
- ->indent()
- ->write("ob_end_clean();\n\n")
- ->write("throw \$e;\n")
- ->outdent()
- ->write("} catch (Throwable \$e) {\n")
- ->indent()
- ->write("ob_end_clean();\n\n")
- ->write("throw \$e;\n")
- ->outdent()
- ->write("}\n\n")
- ->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n")
- ->outdent()
- ->write("}\n\n")
- ;
- }
-}
-
-class_alias('Twig_Node_Macro', 'Twig\Node\MacroNode', false);
diff --git a/inc/lib/Twig/Node/Module.php b/inc/lib/Twig/Node/Module.php
deleted file mode 100644
index 5cd8d050..00000000
--- a/inc/lib/Twig/Node/Module.php
+++ /dev/null
@@ -1,461 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a module node.
- *
- * Consider this class as being final. If you need to customize the behavior of
- * the generated class, consider adding nodes to the following nodes: display_start,
- * display_end, constructor_start, constructor_end, and class_end.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Module extends Twig_Node
-{
- private $source;
-
- public function __construct(Twig_NodeInterface $body, Twig_Node_Expression $parent = null, Twig_NodeInterface $blocks, Twig_NodeInterface $macros, Twig_NodeInterface $traits, $embeddedTemplates, $name, $source = '')
- {
- if (!$name instanceof Twig_Source) {
- @trigger_error(sprintf('Passing a string as the $name argument of %s() is deprecated since version 1.27. Pass a Twig_Source instance instead.', __METHOD__), E_USER_DEPRECATED);
- $this->source = new Twig_Source($source, $name);
- } else {
- $this->source = $name;
- }
-
- $nodes = array(
- 'body' => $body,
- 'blocks' => $blocks,
- 'macros' => $macros,
- 'traits' => $traits,
- 'display_start' => new Twig_Node(),
- 'display_end' => new Twig_Node(),
- 'constructor_start' => new Twig_Node(),
- 'constructor_end' => new Twig_Node(),
- 'class_end' => new Twig_Node(),
- );
- if (null !== $parent) {
- $nodes['parent'] = $parent;
- }
-
- // embedded templates are set as attributes so that they are only visited once by the visitors
- parent::__construct($nodes, array(
- // source to be remove in 2.0
- 'source' => $this->source->getCode(),
- // filename to be remove in 2.0 (use getTemplateName() instead)
- 'filename' => $this->source->getName(),
- 'index' => null,
- 'embedded_templates' => $embeddedTemplates,
- ), 1);
-
- // populate the template name of all node children
- $this->setTemplateName($this->source->getName());
- }
-
- public function setIndex($index)
- {
- $this->setAttribute('index', $index);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $this->compileTemplate($compiler);
-
- foreach ($this->getAttribute('embedded_templates') as $template) {
- $compiler->subcompile($template);
- }
- }
-
- protected function compileTemplate(Twig_Compiler $compiler)
- {
- if (!$this->getAttribute('index')) {
- $compiler->write('<?php');
- }
-
- $this->compileClassHeader($compiler);
-
- if (
- count($this->getNode('blocks'))
- || count($this->getNode('traits'))
- || !$this->hasNode('parent')
- || $this->getNode('parent') instanceof Twig_Node_Expression_Constant
- || count($this->getNode('constructor_start'))
- || count($this->getNode('constructor_end'))
- ) {
- $this->compileConstructor($compiler);
- }
-
- $this->compileGetParent($compiler);
-
- $this->compileDisplay($compiler);
-
- $compiler->subcompile($this->getNode('blocks'));
-
- $this->compileMacros($compiler);
-
- $this->compileGetTemplateName($compiler);
-
- $this->compileIsTraitable($compiler);
-
- $this->compileDebugInfo($compiler);
-
- $this->compileGetSource($compiler);
-
- $this->compileGetSourceContext($compiler);
-
- $this->compileClassFooter($compiler);
- }
-
- protected function compileGetParent(Twig_Compiler $compiler)
- {
- if (!$this->hasNode('parent')) {
- return;
- }
- $parent = $this->getNode('parent');
-
- $compiler
- ->write("protected function doGetParent(array \$context)\n", "{\n")
- ->indent()
- ->addDebugInfo($parent)
- ->write('return ')
- ;
-
- if ($parent instanceof Twig_Node_Expression_Constant) {
- $compiler->subcompile($parent);
- } else {
- $compiler
- ->raw('$this->loadTemplate(')
- ->subcompile($parent)
- ->raw(', ')
- ->repr($this->source->getName())
- ->raw(', ')
- ->repr($parent->getTemplateLine())
- ->raw(')')
- ;
- }
-
- $compiler
- ->raw(";\n")
- ->outdent()
- ->write("}\n\n")
- ;
- }
-
- protected function compileClassHeader(Twig_Compiler $compiler)
- {
- $compiler
- ->write("\n\n")
- // if the template name contains */, add a blank to avoid a PHP parse error
- ->write('/* '.str_replace('*/', '* /', $this->source->getName())." */\n")
- ->write('class '.$compiler->getEnvironment()->getTemplateClass($this->source->getName(), $this->getAttribute('index')))
- ->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->getBaseTemplateClass()))
- ->write("{\n")
- ->indent()
- ;
- }
-
- protected function compileConstructor(Twig_Compiler $compiler)
- {
- $compiler
- ->write("public function __construct(Twig_Environment \$env)\n", "{\n")
- ->indent()
- ->subcompile($this->getNode('constructor_start'))
- ->write("parent::__construct(\$env);\n\n")
- ;
-
- // parent
- if (!$this->hasNode('parent')) {
- $compiler->write("\$this->parent = false;\n\n");
- } elseif (($parent = $this->getNode('parent')) && $parent instanceof Twig_Node_Expression_Constant) {
- $compiler
- ->addDebugInfo($parent)
- ->write('$this->parent = $this->loadTemplate(')
- ->subcompile($parent)
- ->raw(', ')
- ->repr($this->source->getName())
- ->raw(', ')
- ->repr($parent->getTemplateLine())
- ->raw(");\n")
- ;
- }
-
- $countTraits = count($this->getNode('traits'));
- if ($countTraits) {
- // traits
- foreach ($this->getNode('traits') as $i => $trait) {
- $this->compileLoadTemplate($compiler, $trait->getNode('template'), sprintf('$_trait_%s', $i));
-
- $compiler
- ->addDebugInfo($trait->getNode('template'))
- ->write(sprintf("if (!\$_trait_%s->isTraitable()) {\n", $i))
- ->indent()
- ->write("throw new Twig_Error_Runtime('Template \"'.")
- ->subcompile($trait->getNode('template'))
- ->raw(".'\" cannot be used as a trait.');\n")
- ->outdent()
- ->write("}\n")
- ->write(sprintf("\$_trait_%s_blocks = \$_trait_%s->getBlocks();\n\n", $i, $i))
- ;
-
- foreach ($trait->getNode('targets') as $key => $value) {
- $compiler
- ->write(sprintf('if (!isset($_trait_%s_blocks[', $i))
- ->string($key)
- ->raw("])) {\n")
- ->indent()
- ->write("throw new Twig_Error_Runtime(sprintf('Block ")
- ->string($key)
- ->raw(' is not defined in trait ')
- ->subcompile($trait->getNode('template'))
- ->raw(".'));\n")
- ->outdent()
- ->write("}\n\n")
-
- ->write(sprintf('$_trait_%s_blocks[', $i))
- ->subcompile($value)
- ->raw(sprintf('] = $_trait_%s_blocks[', $i))
- ->string($key)
- ->raw(sprintf(']; unset($_trait_%s_blocks[', $i))
- ->string($key)
- ->raw("]);\n\n")
- ;
- }
- }
-
- if ($countTraits > 1) {
- $compiler
- ->write("\$this->traits = array_merge(\n")
- ->indent()
- ;
-
- for ($i = 0; $i < $countTraits; ++$i) {
- $compiler
- ->write(sprintf('$_trait_%s_blocks'.($i == $countTraits - 1 ? '' : ',')."\n", $i))
- ;
- }
-
- $compiler
- ->outdent()
- ->write(");\n\n")
- ;
- } else {
- $compiler
- ->write("\$this->traits = \$_trait_0_blocks;\n\n")
- ;
- }
-
- $compiler
- ->write("\$this->blocks = array_merge(\n")
- ->indent()
- ->write("\$this->traits,\n")
- ->write("array(\n")
- ;
- } else {
- $compiler
- ->write("\$this->blocks = array(\n")
- ;
- }
-
- // blocks
- $compiler
- ->indent()
- ;
-
- foreach ($this->getNode('blocks') as $name => $node) {
- $compiler
- ->write(sprintf("'%s' => array(\$this, 'block_%s'),\n", $name, $name))
- ;
- }
-
- if ($countTraits) {
- $compiler
- ->outdent()
- ->write(")\n")
- ;
- }
-
- $compiler
- ->outdent()
- ->write(");\n")
- ->outdent()
- ->subcompile($this->getNode('constructor_end'))
- ->write("}\n\n")
- ;
- }
-
- protected function compileDisplay(Twig_Compiler $compiler)
- {
- $compiler
- ->write("protected function doDisplay(array \$context, array \$blocks = array())\n", "{\n")
- ->indent()
- ->subcompile($this->getNode('display_start'))
- ->subcompile($this->getNode('body'))
- ;
-
- if ($this->hasNode('parent')) {
- $parent = $this->getNode('parent');
- $compiler->addDebugInfo($parent);
- if ($parent instanceof Twig_Node_Expression_Constant) {
- $compiler->write('$this->parent');
- } else {
- $compiler->write('$this->getParent($context)');
- }
- $compiler->raw("->display(\$context, array_merge(\$this->blocks, \$blocks));\n");
- }
-
- $compiler
- ->subcompile($this->getNode('display_end'))
- ->outdent()
- ->write("}\n\n")
- ;
- }
-
- protected function compileClassFooter(Twig_Compiler $compiler)
- {
- $compiler
- ->subcompile($this->getNode('class_end'))
- ->outdent()
- ->write("}\n")
- ;
- }
-
- protected function compileMacros(Twig_Compiler $compiler)
- {
- $compiler->subcompile($this->getNode('macros'));
- }
-
- protected function compileGetTemplateName(Twig_Compiler $compiler)
- {
- $compiler
- ->write("public function getTemplateName()\n", "{\n")
- ->indent()
- ->write('return ')
- ->repr($this->source->getName())
- ->raw(";\n")
- ->outdent()
- ->write("}\n\n")
- ;
- }
-
- protected function compileIsTraitable(Twig_Compiler $compiler)
- {
- // A template can be used as a trait if:
- // * it has no parent
- // * it has no macros
- // * it has no body
- //
- // Put another way, a template can be used as a trait if it
- // only contains blocks and use statements.
- $traitable = !$this->hasNode('parent') && 0 === count($this->getNode('macros'));
- if ($traitable) {
- if ($this->getNode('body') instanceof Twig_Node_Body) {
- $nodes = $this->getNode('body')->getNode(0);
- } else {
- $nodes = $this->getNode('body');
- }
-
- if (!count($nodes)) {
- $nodes = new Twig_Node(array($nodes));
- }
-
- foreach ($nodes as $node) {
- if (!count($node)) {
- continue;
- }
-
- if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) {
- continue;
- }
-
- if ($node instanceof Twig_Node_BlockReference) {
- continue;
- }
-
- $traitable = false;
- break;
- }
- }
-
- if ($traitable) {
- return;
- }
-
- $compiler
- ->write("public function isTraitable()\n", "{\n")
- ->indent()
- ->write(sprintf("return %s;\n", $traitable ? 'true' : 'false'))
- ->outdent()
- ->write("}\n\n")
- ;
- }
-
- protected function compileDebugInfo(Twig_Compiler $compiler)
- {
- $compiler
- ->write("public function getDebugInfo()\n", "{\n")
- ->indent()
- ->write(sprintf("return %s;\n", str_replace("\n", '', var_export(array_reverse($compiler->getDebugInfo(), true), true))))
- ->outdent()
- ->write("}\n\n")
- ;
- }
-
- protected function compileGetSource(Twig_Compiler $compiler)
- {
- $compiler
- ->write("/** @deprecated since 1.27 (to be removed in 2.0). Use getSourceContext() instead */\n")
- ->write("public function getSource()\n", "{\n")
- ->indent()
- ->write("@trigger_error('The '.__METHOD__.' method is deprecated since version 1.27 and will be removed in 2.0. Use getSourceContext() instead.', E_USER_DEPRECATED);\n\n")
- ->write('return $this->getSourceContext()->getCode();')
- ->raw("\n")
- ->outdent()
- ->write("}\n\n")
- ;
- }
-
- protected function compileGetSourceContext(Twig_Compiler $compiler)
- {
- $compiler
- ->write("public function getSourceContext()\n", "{\n")
- ->indent()
- ->write('return new Twig_Source(')
- ->string($compiler->getEnvironment()->isDebug() ? $this->source->getCode() : '')
- ->raw(', ')
- ->string($this->source->getName())
- ->raw(', ')
- ->string($this->source->getPath())
- ->raw(");\n")
- ->outdent()
- ->write("}\n")
- ;
- }
-
- protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var)
- {
- if ($node instanceof Twig_Node_Expression_Constant) {
- $compiler
- ->write(sprintf('%s = $this->loadTemplate(', $var))
- ->subcompile($node)
- ->raw(', ')
- ->repr($node->getTemplateName())
- ->raw(', ')
- ->repr($node->getTemplateLine())
- ->raw(");\n")
- ;
- } else {
- throw new LogicException('Trait templates can only be constant nodes.');
- }
- }
-}
-
-class_alias('Twig_Node_Module', 'Twig\Node\ModuleNode', false);
diff --git a/inc/lib/Twig/Node/Print.php b/inc/lib/Twig/Node/Print.php
deleted file mode 100644
index 374db89b..00000000
--- a/inc/lib/Twig/Node/Print.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a node that outputs an expression.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface
-{
- public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
- {
- parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write('echo ')
- ->subcompile($this->getNode('expr'))
- ->raw(";\n")
- ;
- }
-}
-
-class_alias('Twig_Node_Print', 'Twig\Node\PrintNode', false);
diff --git a/inc/lib/Twig/Node/Sandbox.php b/inc/lib/Twig/Node/Sandbox.php
deleted file mode 100644
index 44b30ab9..00000000
--- a/inc/lib/Twig/Node/Sandbox.php
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a sandbox node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Sandbox extends Twig_Node
-{
- public function __construct(Twig_NodeInterface $body, $lineno, $tag = null)
- {
- parent::__construct(array('body' => $body), array(), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write("\$sandbox = \$this->env->getExtension('Twig_Extension_Sandbox');\n")
- ->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n")
- ->indent()
- ->write("\$sandbox->enableSandbox();\n")
- ->outdent()
- ->write("}\n")
- ->subcompile($this->getNode('body'))
- ->write("if (!\$alreadySandboxed) {\n")
- ->indent()
- ->write("\$sandbox->disableSandbox();\n")
- ->outdent()
- ->write("}\n")
- ;
- }
-}
-
-class_alias('Twig_Node_Sandbox', 'Twig\Node\SandboxNode', false);
diff --git a/inc/lib/Twig/Node/SandboxedModule.php b/inc/lib/Twig/Node/SandboxedModule.php
deleted file mode 100644
index be1f5daa..00000000
--- a/inc/lib/Twig/Node/SandboxedModule.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) 2009 Fabien Potencier
- * (c) 2009 Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a module node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_SandboxedModule extends Twig_Node_Module
-{
- protected $usedFilters;
- protected $usedTags;
- protected $usedFunctions;
-
- public function __construct(Twig_Node_Module $node, array $usedFilters, array $usedTags, array $usedFunctions)
- {
- parent::__construct($node->getNode('body'), $node->getNode('parent'), $node->getNode('blocks'), $node->getNode('macros'), $node->getNode('traits'), $node->getAttribute('embedded_templates'), $node->getAttribute('filename'), $node->getLine(), $node->getNodeTag());
-
- $this->setAttribute('index', $node->getAttribute('index'));
-
- $this->usedFilters = $usedFilters;
- $this->usedTags = $usedTags;
- $this->usedFunctions = $usedFunctions;
- }
-
- protected function compileDisplayBody(Twig_Compiler $compiler)
- {
- $compiler->write("\$this->checkSecurity();\n");
-
- parent::compileDisplayBody($compiler);
- }
-
- protected function compileDisplayFooter(Twig_Compiler $compiler)
- {
- parent::compileDisplayFooter($compiler);
-
- $compiler
- ->write("protected function checkSecurity()\n", "{\n")
- ->indent()
- ->write("\$this->env->getExtension('sandbox')->checkSecurity(\n")
- ->indent()
- ->write(!$this->usedTags ? "array(),\n" : "array('".implode('\', \'', $this->usedTags)."'),\n")
- ->write(!$this->usedFilters ? "array(),\n" : "array('".implode('\', \'', $this->usedFilters)."'),\n")
- ->write(!$this->usedFunctions ? "array()\n" : "array('".implode('\', \'', $this->usedFunctions)."')\n")
- ->outdent()
- ->write(");\n")
- ->outdent()
- ->write("}\n\n")
- ;
- }
-}
diff --git a/inc/lib/Twig/Node/SandboxedPrint.php b/inc/lib/Twig/Node/SandboxedPrint.php
deleted file mode 100644
index a08f21f5..00000000
--- a/inc/lib/Twig/Node/SandboxedPrint.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Twig_Node_SandboxedPrint adds a check for the __toString() method
- * when the variable is an object and the sandbox is activated.
- *
- * When there is a simple Print statement, like {{ article }},
- * and if the sandbox is enabled, we need to check that the __toString()
- * method is allowed if 'article' is an object.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_SandboxedPrint extends Twig_Node_Print
-{
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write('echo $this->env->getExtension(\'Twig_Extension_Sandbox\')->ensureToStringAllowed(')
- ->subcompile($this->getNode('expr'))
- ->raw(");\n")
- ;
- }
-
- /**
- * Removes node filters.
- *
- * This is mostly needed when another visitor adds filters (like the escaper one).
- *
- * @return Twig_Node
- */
- protected function removeNodeFilter(Twig_Node $node)
- {
- if ($node instanceof Twig_Node_Expression_Filter) {
- return $this->removeNodeFilter($node->getNode('node'));
- }
-
- return $node;
- }
-}
-
-class_alias('Twig_Node_SandboxedPrint', 'Twig\Node\SandboxedPrintNode', false);
diff --git a/inc/lib/Twig/Node/Set.php b/inc/lib/Twig/Node/Set.php
deleted file mode 100644
index 6c6743ee..00000000
--- a/inc/lib/Twig/Node/Set.php
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a set node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Set extends Twig_Node implements Twig_NodeCaptureInterface
-{
- public function __construct($capture, Twig_NodeInterface $names, Twig_NodeInterface $values, $lineno, $tag = null)
- {
- parent::__construct(array('names' => $names, 'values' => $values), array('capture' => $capture, 'safe' => false), $lineno, $tag);
-
- /*
- * Optimizes the node when capture is used for a large block of text.
- *
- * {% set foo %}foo{% endset %} is compiled to $context['foo'] = new Twig_Markup("foo");
- */
- if ($this->getAttribute('capture')) {
- $this->setAttribute('safe', true);
-
- $values = $this->getNode('values');
- if ($values instanceof Twig_Node_Text) {
- $this->setNode('values', new Twig_Node_Expression_Constant($values->getAttribute('data'), $values->getTemplateLine()));
- $this->setAttribute('capture', false);
- }
- }
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->addDebugInfo($this);
-
- if (count($this->getNode('names')) > 1) {
- $compiler->write('list(');
- foreach ($this->getNode('names') as $idx => $node) {
- if ($idx) {
- $compiler->raw(', ');
- }
-
- $compiler->subcompile($node);
- }
- $compiler->raw(')');
- } else {
- if ($this->getAttribute('capture')) {
- $compiler
- ->write("ob_start();\n")
- ->subcompile($this->getNode('values'))
- ;
- }
-
- $compiler->subcompile($this->getNode('names'), false);
-
- if ($this->getAttribute('capture')) {
- $compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())");
- }
- }
-
- if (!$this->getAttribute('capture')) {
- $compiler->raw(' = ');
-
- if (count($this->getNode('names')) > 1) {
- $compiler->write('array(');
- foreach ($this->getNode('values') as $idx => $value) {
- if ($idx) {
- $compiler->raw(', ');
- }
-
- $compiler->subcompile($value);
- }
- $compiler->raw(')');
- } else {
- if ($this->getAttribute('safe')) {
- $compiler
- ->raw("('' === \$tmp = ")
- ->subcompile($this->getNode('values'))
- ->raw(") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())")
- ;
- } else {
- $compiler->subcompile($this->getNode('values'));
- }
- }
- }
-
- $compiler->raw(";\n");
- }
-}
-
-class_alias('Twig_Node_Set', 'Twig\Node\SetNode', false);
diff --git a/inc/lib/Twig/Node/SetTemp.php b/inc/lib/Twig/Node/SetTemp.php
deleted file mode 100644
index 996fdcde..00000000
--- a/inc/lib/Twig/Node/SetTemp.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * @internal
- */
-class Twig_Node_SetTemp extends Twig_Node
-{
- public function __construct($name, $lineno)
- {
- parent::__construct(array(), array('name' => $name), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $name = $this->getAttribute('name');
- $compiler
- ->addDebugInfo($this)
- ->write('if (isset($context[')
- ->string($name)
- ->raw('])) { $_')
- ->raw($name)
- ->raw('_ = $context[')
- ->repr($name)
- ->raw(']; } else { $_')
- ->raw($name)
- ->raw("_ = null; }\n")
- ;
- }
-}
-
-class_alias('Twig_Node_SetTemp', 'Twig\Node\SetTempNode', false);
diff --git a/inc/lib/Twig/Node/Spaceless.php b/inc/lib/Twig/Node/Spaceless.php
deleted file mode 100644
index 76f90cde..00000000
--- a/inc/lib/Twig/Node/Spaceless.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a spaceless node.
- *
- * It removes spaces between HTML tags.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Spaceless extends Twig_Node
-{
- public function __construct(Twig_NodeInterface $body, $lineno, $tag = 'spaceless')
- {
- parent::__construct(array('body' => $body), array(), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write("ob_start();\n")
- ->subcompile($this->getNode('body'))
- ->write("echo trim(preg_replace('/>\s+</', '><', ob_get_clean()));\n")
- ;
- }
-}
-
-class_alias('Twig_Node_Spaceless', 'Twig\Node\SpacelessNode', false);
diff --git a/inc/lib/Twig/Node/Text.php b/inc/lib/Twig/Node/Text.php
deleted file mode 100644
index f4577fee..00000000
--- a/inc/lib/Twig/Node/Text.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- * (c) Armin Ronacher
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a text node.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface
-{
- public function __construct($data, $lineno)
- {
- parent::__construct(array(), array('data' => $data), $lineno);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler
- ->addDebugInfo($this)
- ->write('echo ')
- ->string($this->getAttribute('data'))
- ->raw(";\n")
- ;
- }
-}
-
-class_alias('Twig_Node_Text', 'Twig\Node\TextNode', false);
diff --git a/inc/lib/Twig/Node/With.php b/inc/lib/Twig/Node/With.php
deleted file mode 100644
index 2ab0ea5d..00000000
--- a/inc/lib/Twig/Node/With.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-/*
- * This file is part of Twig.
- *
- * (c) Fabien Potencier
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-
-/**
- * Represents a nested "with" scope.
- *
- * @author Fabien Potencier <fabien@symfony.com>
- */
-class Twig_Node_With extends Twig_Node
-{
- public function __construct(Twig_Node $body, Twig_Node $variables = null, $only = false, $lineno, $tag = null)
- {
- $nodes = array('body' => $body);
- if (null !== $variables) {
- $nodes['variables'] = $variables;
- }
-
- parent::__construct($nodes, array('only' => (bool) $only), $lineno, $tag);
- }
-
- public function compile(Twig_Compiler $compiler)
- {
- $compiler->addDebugInfo($this);
-
- if ($this->hasNode('variables')) {
- $varsName = $compiler->getVarName();
- $compiler
- ->write(sprintf('$%s = ', $varsName))
- ->subcompile($this->getNode('variables'))
- ->raw(";\n")
- ->write(sprintf("if (!is_array(\$%s)) {\n", $varsName))
- ->indent()
- ->write("throw new Twig_Error_Runtime('Variables passed to the \"with\" tag must be a hash.');\n")
- ->outdent()
- ->write("}\n")
- ;
-
- if ($this->getAttribute('only')) {
- $compiler->write("\$context = array('_parent' => \$context);\n");
- } else {
- $compiler->write("\$context['_parent'] = \$context;\n");
- }
-
- $compiler->write(sprintf("\$context = array_merge(\$context, \$%s);\n", $varsName));
- } else {
- $compiler->write("\$context['_parent'] = \$context;\n");
- }
-
- $compiler
- ->subcompile($this->getNode('body'))
- ->write("\$context = \$context['_parent'];\n")
- ;
- }
-}
-
-class_alias('Twig_Node_With', 'Twig\Node\WithNode', false);