1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-02 17:28:27 +01:00
PHP-Parser/test/code/parser/stmt/loop/for.test

110 lines
2.0 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) {}
// multiple expressions
for ($a, $b; $c, $d; $e, $f) {}
2011-11-27 11:20:35 +01:00
// 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(
)
comments: array(
0: // "classical" loop
)
2011-11-27 11:20:35 +01:00
)
1: Stmt_For(
2015-10-01 17:32:51 +02:00
init: array(
0: Expr_Variable(
name: a
2015-10-01 17:32:51 +02:00
)
1: Expr_Variable(
name: b
2015-10-01 17:32:51 +02:00
)
)
cond: array(
0: Expr_Variable(
name: c
2015-10-01 17:32:51 +02:00
)
1: Expr_Variable(
name: d
2015-10-01 17:32:51 +02:00
)
)
loop: array(
2011-11-27 11:20:35 +01:00
0: Expr_Variable(
name: e
2011-11-27 11:20:35 +01:00
)
1: Expr_Variable(
name: f
2011-11-27 11:20:35 +01:00
)
)
stmts: array(
)
comments: array(
0: // multiple expressions
)
2011-11-27 11:20:35 +01:00
)
2: Stmt_For(
2011-11-27 11:20:35 +01:00
init: array(
)
cond: array(
)
loop: array(
)
stmts: array(
)
comments: array(
0: // infinite loop
)
2011-11-27 11:20:35 +01:00
)
3: Stmt_For(
2011-11-27 11:20:35 +01:00
init: array(
)
cond: array(
)
loop: array(
)
stmts: array(
)
comments: array(
0: // alternative syntax
)
2011-11-27 11:20:35 +01:00
)
)