Skip to content

Commit

Permalink
merged branch nikic/fixLoopIncrement (PR twigphp#563)
Browse files Browse the repository at this point in the history
Commits
-------

8255b8b Fix test for previous commit
834ce4c Fix loop increment on some for loops (fix twigphp#562)

Discussion
----------

Fix loop increment

PR for twigphp#562.
  • Loading branch information
fabpot committed Dec 21, 2011
2 parents 6f020cc + 8255b8b commit 2d21619
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Twig/Node/For.php
Expand Up @@ -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_ForLoop($lineno, $tag));
$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);
Expand Down
2 changes: 1 addition & 1 deletion test/Twig/Tests/Node/ForTest.php
Expand Up @@ -32,7 +32,7 @@ public function testConstructor()
$this->assertEquals($seq, $node->getNode('seq'));
$this->assertTrue($node->getAttribute('ifexpr'));
$this->assertInstanceOf('Twig_Node_If', $node->getNode('body'));
$this->assertEquals($body, $node->getNode('body')->getNode('tests')->getNode(1));
$this->assertEquals($body, $node->getNode('body')->getNode('tests')->getNode(1)->getNode(0));
$this->assertEquals(null, $node->getNode('else'));

$else = new Twig_Node_Print(new Twig_Node_Expression_Name('foo', 0), 0);
Expand Down

0 comments on commit 2d21619

Please sign in to comment.