php-parser/test/code/parser/stmt/loop/for.test

128 lines
2.4 KiB
Plaintext
Raw Normal View History

2011-11-27 11:20:35 +01:00
For loop
-----
<?php
// "classical" loop
for ($i = 0; $i < $c; ++$i) {}
2015-10-01 17:32:51 +02:00
// "classical" loop + multiple init
for ($i = 0, $j = 0; $i < $c; ++$i) {}
2011-11-27 11:20:35 +01:00
// multiple expressions
for (;$a,$b;) {}
// 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(
2011-11-27 11:20:35 +01:00
left: Expr_Variable(
name: i
)
right: Expr_Variable(
name: c
)
)
)
loop: array(
0: Expr_PreInc(
var: Expr_Variable(
name: i
)
)
)
stmts: array(
)
)
1: Stmt_For(
2015-10-01 17:32:51 +02:00
init: array(
0: Expr_Assign(
var: Expr_Variable(
name: i
)
expr: Scalar_LNumber(
value: 0
)
)
1: Expr_Assign(
var: Expr_Variable(
name: j
)
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(
)
)
2: Stmt_For(
2011-11-27 11:20:35 +01:00
init: array(
)
cond: array(
0: Expr_Variable(
name: a
)
1: Expr_Variable(
name: b
)
)
loop: array(
)
stmts: array(
)
)
2015-10-01 17:32:51 +02:00
3: Stmt_For(
2011-11-27 11:20:35 +01:00
init: array(
)
cond: array(
)
loop: array(
)
stmts: array(
)
)
2015-10-01 17:32:51 +02:00
4: Stmt_For(
2011-11-27 11:20:35 +01:00
init: array(
)
cond: array(
)
loop: array(
)
stmts: array(
)
)
)