22 $node =
new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
23 $node->setAttribute(
'with_loop',
false);
25 $this->assertEquals($keyTarget, $node->getNode(
'key_target'));
26 $this->assertEquals($valueTarget, $node->getNode(
'value_target'));
27 $this->assertEquals($seq, $node->getNode(
'seq'));
28 $this->assertTrue($node->getAttribute(
'ifexpr'));
29 $this->assertEquals(
'Twig_Node_If', get_class($node->getNode(
'body')));
30 $this->assertEquals($body, $node->getNode(
'body')->getNode(
'tests')->getNode(1)->getNode(0));
31 $this->assertFalse($node->hasNode(
'else'));
34 $node =
new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
35 $node->setAttribute(
'with_loop',
false);
36 $this->assertEquals($else, $node->getNode(
'else'));
49 $node =
new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
50 $node->setAttribute(
'with_loop',
false);
54 \$context[
'_parent'] = \$context;
56 foreach (\$context[
'_seq'] as \$context[
"key"] => \$context[
"item"]) {
59 \$_parent = \$context[
'_parent'];
60 unset(\$context[
'_seq'], \$context[
'_iterated'], \$context[
'key'], \$context[
'item'], \$context[
'_parent'], \$context[
'loop']);
61 \$context = array_intersect_key(\$context, \$_parent) + \$_parent;
71 $node =
new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
72 $node->setAttribute(
'with_loop',
true);
76 \$context[
'_parent'] = \$context;
77 \$context[
'_seq'] = twig_ensure_traversable({$this->
getVariableGetter(
'values')});
78 \$context[
'loop'] =
array(
79 'parent' => \$context[
'_parent'],
84 if (is_array(\$context[
'_seq']) || (is_object(\$context[
'_seq']) && \$context[
'_seq'] instanceof
Countable)) {
85 \$length = count(\$context[
'_seq']);
86 \$context[
'loop'][
'revindex0'] = \$length - 1;
87 \$context[
'loop'][
'revindex'] = \$length;
88 \$context[
'loop'][
'length'] = \$length;
89 \$context[
'loop'][
'last'] = 1 === \$length;
91 foreach (\$context[
'_seq'] as \$context[
"k"] => \$context[
"v"]) {
93 ++\$context[
'loop'][
'index0'];
94 ++\$context[
'loop'][
'index'];
95 \$context[
'loop'][
'first'] =
false;
96 if (isset(\$context[
'loop'][
'length'])) {
97 --\$context[
'loop'][
'revindex0'];
98 --\$context[
'loop'][
'revindex'];
99 \$context[
'loop'][
'last'] = 0 === \$context[
'loop'][
'revindex0'];
102 \$_parent = \$context[
'_parent'];
103 unset(\$context[
'_seq'], \$context[
'_iterated'], \$context[
'k'], \$context[
'v'], \$context[
'_parent'], \$context[
'loop']);
104 \$context = array_intersect_key(\$context, \$_parent) + \$_parent;
114 $node =
new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
115 $node->setAttribute(
'with_loop',
true);
119 \$context[
'_parent'] = \$context;
120 \$context[
'_seq'] = twig_ensure_traversable({$this->
getVariableGetter(
'values')});
121 \$context[
'loop'] =
array(
122 'parent' => \$context[
'_parent'],
127 foreach (\$context[
'_seq'] as \$context[
"k"] => \$context[
"v"]) {
130 ++\$context[
'loop'][
'index0'];
131 ++\$context[
'loop'][
'index'];
132 \$context[
'loop'][
'first'] =
false;
135 \$_parent = \$context[
'_parent'];
136 unset(\$context[
'_seq'], \$context[
'_iterated'], \$context[
'k'], \$context[
'v'], \$context[
'_parent'], \$context[
'loop']);
137 \$context = array_intersect_key(\$context, \$_parent) + \$_parent;
147 $node =
new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, 1);
148 $node->setAttribute(
'with_loop',
true);
152 \$context[
'_parent'] = \$context;
153 \$context[
'_seq'] = twig_ensure_traversable({$this->
getVariableGetter(
'values')});
154 \$context[
'_iterated'] =
false;
155 \$context[
'loop'] =
array(
156 'parent' => \$context[
'_parent'],
161 if (is_array(\$context[
'_seq']) || (is_object(\$context[
'_seq']) && \$context[
'_seq'] instanceof Countable)) {
162 \$length = count(\$context[
'_seq']);
163 \$context[
'loop'][
'revindex0'] = \$length - 1;
164 \$context[
'loop'][
'revindex'] = \$length;
165 \$context[
'loop'][
'length'] = \$length;
166 \$context[
'loop'][
'last'] = 1 === \$length;
168 foreach (\$context[
'_seq'] as \$context[
"k"] => \$context[
"v"]) {
170 \$context[
'_iterated'] =
true;
171 ++\$context[
'loop'][
'index0'];
172 ++\$context[
'loop'][
'index'];
173 \$context[
'loop'][
'first'] =
false;
174 if (isset(\$context[
'loop'][
'length'])) {
175 --\$context[
'loop'][
'revindex0'];
176 --\$context[
'loop'][
'revindex'];
177 \$context[
'loop'][
'last'] = 0 === \$context[
'loop'][
'revindex0'];
180 if (!\$context[
'_iterated']) {
183 \$_parent = \$context[
'_parent'];
184 unset(\$context[
'_seq'], \$context[
'_iterated'], \$context[
'k'], \$context[
'v'], \$context[
'_parent'], \$context[
'loop']);
185 \$context = array_intersect_key(\$context, \$_parent) + \$_parent;
Represents a node in the AST.
Represents a node that outputs an expression.
Create styles array
The data for the language used.
getVariableGetter($name, $line=false)
const EOF
How fgetc() reports an End Of File.