->write(" 'index' => 1,\n")
->write(" 'first' => true,\n")
->write(");\n")
- ->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")
;
+
+ if (null === $this->getNode('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")
+ ;
+ }
}
$compiler
if (null !== $this->getNode('ifexpr')) {
$compiler
- ->write("if (")
+ ->write("if (!(")
->subcompile($this->getNode('ifexpr'))
- ->raw(") {\n")
+ ->raw(")) {\n")
->indent()
+ ->write("continue;\n")
+ ->outdent()
+ ->write("}\n\n")
;
}
->write("++\$context['loop']['index0'];\n")
->write("++\$context['loop']['index'];\n")
->write("\$context['loop']['first'] = false;\n")
- ->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")
;
- }
- if (null !== $this->getNode('ifexpr')) {
- $compiler
- ->outdent()
- ->write("}\n")
- ;
+ if (null === $this->getNode('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")
+ ;
+ }
}
$compiler
'index' => 1,
'first' => true,
);
-if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {
- \$length = count(\$context['_seq']);
- \$context['loop']['revindex0'] = \$length - 1;
- \$context['loop']['revindex'] = \$length;
- \$context['loop']['length'] = \$length;
- \$context['loop']['last'] = 1 === \$length;
-}
foreach (\$context['_seq'] as \$context['k'] => \$context['v']) {
- if (true) {
- echo \$this->getContext(\$context, 'foo');
- ++\$context['loop']['index0'];
- ++\$context['loop']['index'];
- \$context['loop']['first'] = false;
- if (isset(\$context['loop']['length'])) {
- --\$context['loop']['revindex0'];
- --\$context['loop']['revindex'];
- \$context['loop']['last'] = 0 === \$context['loop']['revindex0'];
- }
+ if (!(true)) {
+ continue;
}
+
+ echo \$this->getContext(\$context, 'foo');
+ ++\$context['loop']['index0'];
+ ++\$context['loop']['index'];
+ \$context['loop']['first'] = false;
}
\$_parent = \$context['_parent'];
unset(\$context['_seq'], \$context['_iterated'], \$context['k'], \$context['v'], \$context['_parent'], \$context['loop']);