Skip to content

Commit 02e24c5

Browse files
committed
Check if loop exists for continue
Otherwise the variable might not be defined and lead to a PHP notice.
1 parent ce2fb01 commit 02e24c5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/TokenParser/ContinueNode.php

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public function compile(Compiler $compiler)
2323
{
2424
$compiler
2525
->addDebugInfo($this)
26+
->write("if (isset(\$context['loop'])) {\n")
27+
->indent()
2628
// Taken from ForLoopNode - need to do this otherwise the continue skips it
2729
->write("++\$context['loop']['index0'];\n")
2830
->write("++\$context['loop']['index'];\n")
@@ -34,6 +36,9 @@ public function compile(Compiler $compiler)
3436
->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n")
3537
->outdent()
3638
->write("}\n")
39+
// End taken from FoorLoopNode
40+
->outdent()
41+
->write("}\n")
3742
// Do the actual continue operation
3843
->write("continue " . $this->loopNumber . ";\n")
3944
;

0 commit comments

Comments
 (0)