mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-12-03 17:57:59 +01:00
81e53ce0ff
This changset also adds unit tests for Comments and adds a way to test the pretty printer.
72 lines
1.3 KiB
Plaintext
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
|
|
)
|
|
)
|
|
)
|
|
) |