From 620b29a4d5a5cc50ccd810f0a37d8e5392776e6b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 23 Nov 2011 23:45:02 +0100 Subject: [PATCH] renamed an internal class --- lib/Twig/Node/For.php | 2 +- lib/Twig/Node/For/Loop.php | 56 -------------------------------------------- lib/Twig/Node/ForLoop.php | 56 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 57 deletions(-) delete mode 100644 lib/Twig/Node/For/Loop.php create mode 100644 lib/Twig/Node/ForLoop.php diff --git a/lib/Twig/Node/For.php b/lib/Twig/Node/For.php index 0b0e1b6..c8565f1 100644 --- a/lib/Twig/Node/For.php +++ b/lib/Twig/Node/For.php @@ -22,7 +22,7 @@ class Twig_Node_For extends Twig_Node 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->setNode('_for_loop', $this->loop = new Twig_Node_For_Loop($lineno, $tag)); + $body->setNode('_for_loop', $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); diff --git a/lib/Twig/Node/For/Loop.php b/lib/Twig/Node/For/Loop.php deleted file mode 100644 index 45d754e..0000000 --- a/lib/Twig/Node/For/Loop.php +++ /dev/null @@ -1,56 +0,0 @@ - - */ -class Twig_Node_For_Loop extends Twig_Node -{ - public function __construct($lineno, $tag = null) - { - parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - 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") - ; - } - } - } -} diff --git a/lib/Twig/Node/ForLoop.php b/lib/Twig/Node/ForLoop.php new file mode 100644 index 0000000..38f2e85 --- /dev/null +++ b/lib/Twig/Node/ForLoop.php @@ -0,0 +1,56 @@ + + */ +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); + } + + /** + * Compiles the node to PHP. + * + * @param Twig_Compiler A Twig_Compiler instance + */ + 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") + ; + } + } + } +} -- 1.7.2.5