1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-12 09:29:47 +01:00
PHP-Parser/test/code/parser/stmt/loop/for.test
Nikita Popov a0c216bf4b Add dumpComments option to NodeDumper
Adding this as an option to avoid breaking people's tests.

Some of the test results show pretty clearly that we are incorrectly
assigning the same comment multiple times for nested nodes (mentioned
in #36).
2016-03-09 19:48:36 +01:00

110 lines
2.0 KiB
Plaintext

For loop
-----
<?php
// "classical" loop
for ($i = 0; $i < $c; ++$i) {}
// multiple expressions
for ($a, $b; $c, $d; $e, $f) {}
// infinite loop
for (;;) {}
// alternative syntax
for (;;):
endfor;
-----
array(
0: Stmt_For(
init: array(
0: Expr_Assign(
var: Expr_Variable(
name: i
)
expr: Scalar_LNumber(
value: 0
)
)
)
cond: array(
0: Expr_BinaryOp_Smaller(
left: Expr_Variable(
name: i
)
right: Expr_Variable(
name: c
)
)
)
loop: array(
0: Expr_PreInc(
var: Expr_Variable(
name: i
)
)
)
stmts: array(
)
comments: array(
0: // "classical" loop
)
)
1: Stmt_For(
init: array(
0: Expr_Variable(
name: a
)
1: Expr_Variable(
name: b
)
)
cond: array(
0: Expr_Variable(
name: c
)
1: Expr_Variable(
name: d
)
)
loop: array(
0: Expr_Variable(
name: e
)
1: Expr_Variable(
name: f
)
)
stmts: array(
)
comments: array(
0: // multiple expressions
)
)
2: Stmt_For(
init: array(
)
cond: array(
)
loop: array(
)
stmts: array(
)
comments: array(
0: // infinite loop
)
)
3: Stmt_For(
init: array(
)
cond: array(
)
loop: array(
)
stmts: array(
)
comments: array(
0: // alternative syntax
)
)
)