1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-03 17:57:59 +01:00
PHP-Parser/test/code/parser/expr/ternary.test
nikic 81e53ce0ff Insert comments when pretty printing
This changset also adds unit tests for Comments and adds a way to test the
pretty printer.
2012-05-11 16:18:14 +02:00

72 lines
1.3 KiB
Plaintext

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
)
)
)
)