php-parser/test/code/expr/ternary.test

72 lines
1.3 KiB
Plaintext
Raw Normal View History

2011-11-27 11:20:35 +01:00
Ternary operator
-----
<?php
// ternary
$a ? $b : $c;
$a ?: $c;
// precedence
$a ? $b : $c ? $d : $e;
$a ? $b : ($c ? $d : $e);
-----
array(
0: Expr_Ternary(
cond: Expr_Variable(
name: a
)
if: Expr_Variable(
name: b
)
else: Expr_Variable(
name: c
)
)
1: Expr_Ternary(
cond: Expr_Variable(
name: a
)
if: null
else: Expr_Variable(
name: c
)
)
2: Expr_Ternary(
cond: Expr_Ternary(
cond: Expr_Variable(
name: a
)
if: Expr_Variable(
name: b
)
else: Expr_Variable(
name: c
)
)
if: Expr_Variable(
name: d
)
else: Expr_Variable(
name: e
)
)
3: Expr_Ternary(
cond: Expr_Variable(
name: a
)
if: Expr_Variable(
name: b
)
else: Expr_Ternary(
cond: Expr_Variable(
name: c
)
if: Expr_Variable(
name: d
)
else: Expr_Variable(
name: e
)
)
)
)