Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/test/code/parser/expr/ternaryAndCoalesce.test @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children | 5fb285c0d0e3 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 Ternary operator | |
2 ----- | |
3 <?php | |
4 | |
5 // ternary | |
6 $a ? $b : $c; | |
7 $a ?: $c; | |
8 | |
9 // precedence | |
10 $a ? $b : $c ? $d : $e; | |
11 $a ? $b : ($c ? $d : $e); | |
12 | |
13 // null coalesce | |
14 $a ?? $b; | |
15 $a ?? $b ?? $c; | |
16 $a ?? $b ? $c : $d; | |
17 $a && $b ?? $c; | |
18 ----- | |
19 array( | |
20 0: Expr_Ternary( | |
21 cond: Expr_Variable( | |
22 name: a | |
23 comments: array( | |
24 0: // ternary | |
25 ) | |
26 ) | |
27 if: Expr_Variable( | |
28 name: b | |
29 ) | |
30 else: Expr_Variable( | |
31 name: c | |
32 ) | |
33 comments: array( | |
34 0: // ternary | |
35 ) | |
36 ) | |
37 1: Expr_Ternary( | |
38 cond: Expr_Variable( | |
39 name: a | |
40 ) | |
41 if: null | |
42 else: Expr_Variable( | |
43 name: c | |
44 ) | |
45 ) | |
46 2: Expr_Ternary( | |
47 cond: Expr_Ternary( | |
48 cond: Expr_Variable( | |
49 name: a | |
50 comments: array( | |
51 0: // precedence | |
52 ) | |
53 ) | |
54 if: Expr_Variable( | |
55 name: b | |
56 ) | |
57 else: Expr_Variable( | |
58 name: c | |
59 ) | |
60 comments: array( | |
61 0: // precedence | |
62 ) | |
63 ) | |
64 if: Expr_Variable( | |
65 name: d | |
66 ) | |
67 else: Expr_Variable( | |
68 name: e | |
69 ) | |
70 comments: array( | |
71 0: // precedence | |
72 ) | |
73 ) | |
74 3: Expr_Ternary( | |
75 cond: Expr_Variable( | |
76 name: a | |
77 ) | |
78 if: Expr_Variable( | |
79 name: b | |
80 ) | |
81 else: Expr_Ternary( | |
82 cond: Expr_Variable( | |
83 name: c | |
84 ) | |
85 if: Expr_Variable( | |
86 name: d | |
87 ) | |
88 else: Expr_Variable( | |
89 name: e | |
90 ) | |
91 ) | |
92 ) | |
93 4: Expr_BinaryOp_Coalesce( | |
94 left: Expr_Variable( | |
95 name: a | |
96 comments: array( | |
97 0: // null coalesce | |
98 ) | |
99 ) | |
100 right: Expr_Variable( | |
101 name: b | |
102 ) | |
103 comments: array( | |
104 0: // null coalesce | |
105 ) | |
106 ) | |
107 5: Expr_BinaryOp_Coalesce( | |
108 left: Expr_Variable( | |
109 name: a | |
110 ) | |
111 right: Expr_BinaryOp_Coalesce( | |
112 left: Expr_Variable( | |
113 name: b | |
114 ) | |
115 right: Expr_Variable( | |
116 name: c | |
117 ) | |
118 ) | |
119 ) | |
120 6: Expr_Ternary( | |
121 cond: Expr_BinaryOp_Coalesce( | |
122 left: Expr_Variable( | |
123 name: a | |
124 ) | |
125 right: Expr_Variable( | |
126 name: b | |
127 ) | |
128 ) | |
129 if: Expr_Variable( | |
130 name: c | |
131 ) | |
132 else: Expr_Variable( | |
133 name: d | |
134 ) | |
135 ) | |
136 7: Expr_BinaryOp_Coalesce( | |
137 left: Expr_BinaryOp_BooleanAnd( | |
138 left: Expr_Variable( | |
139 name: a | |
140 ) | |
141 right: Expr_Variable( | |
142 name: b | |
143 ) | |
144 ) | |
145 right: Expr_Variable( | |
146 name: c | |
147 ) | |
148 ) | |
149 ) |