123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- Ternary operator
- -----
- <?php
- // ternary
- $a ? $b : $c;
- $a ?: $c;
- // precedence
- $a ? $b : $c ? $d : $e;
- $a ? $b : ($c ? $d : $e);
- // null coalesce
- $a ?? $b;
- $a ?? $b ?? $c;
- $a ?? $b ? $c : $d;
- $a && $b ?? $c;
- -----
- array(
- 0: Expr_Ternary(
- cond: Expr_Variable(
- name: a
- comments: array(
- 0: // ternary
- )
- )
- if: Expr_Variable(
- name: b
- )
- else: Expr_Variable(
- name: c
- )
- comments: array(
- 0: // ternary
- )
- )
- 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
- comments: array(
- 0: // precedence
- )
- )
- if: Expr_Variable(
- name: b
- )
- else: Expr_Variable(
- name: c
- )
- comments: array(
- 0: // precedence
- )
- )
- if: Expr_Variable(
- name: d
- )
- else: Expr_Variable(
- name: e
- )
- comments: array(
- 0: // precedence
- )
- )
- 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
- )
- )
- )
- 4: Expr_BinaryOp_Coalesce(
- left: Expr_Variable(
- name: a
- comments: array(
- 0: // null coalesce
- )
- )
- right: Expr_Variable(
- name: b
- )
- comments: array(
- 0: // null coalesce
- )
- )
- 5: Expr_BinaryOp_Coalesce(
- left: Expr_Variable(
- name: a
- )
- right: Expr_BinaryOp_Coalesce(
- left: Expr_Variable(
- name: b
- )
- right: Expr_Variable(
- name: c
- )
- )
- )
- 6: Expr_Ternary(
- cond: Expr_BinaryOp_Coalesce(
- left: Expr_Variable(
- name: a
- )
- right: Expr_Variable(
- name: b
- )
- )
- if: Expr_Variable(
- name: c
- )
- else: Expr_Variable(
- name: d
- )
- )
- 7: Expr_BinaryOp_Coalesce(
- left: Expr_BinaryOp_BooleanAnd(
- left: Expr_Variable(
- name: a
- )
- right: Expr_Variable(
- name: b
- )
- )
- right: Expr_Variable(
- name: c
- )
- )
- )
|