File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed
Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ --TEST--
2+ Nested match expressions
3+ --FILE--
4+ <?php
5+
6+ // Nested in return expression:
7+ $ b = 'b ' ;
8+ echo match ($ b ) {
9+ 'a ' => 1 ,
10+ 'b ' => match (1 ) {
11+ strpos ('ab ' , $ b ) => 100 ,
12+ default => 15
13+ },
14+ default => 4
15+ };
16+
17+ echo "\n" ;
18+
19+ // Nested in condition expression:
20+ $ c = 'c ' ;
21+ echo match ($ c ) {
22+ 'foo ' => 'bar ' ,
23+ match ($ c ) { default => 'c ' } => 300
24+ };
25+
26+ echo "\n" ;
27+
28+ // Nested in one of many condition expressions:
29+ $ d = 'd ' ;
30+ echo match ($ d ) {
31+ 'foo ' => 'bar ' ,
32+ match ($ d ) { default => 'd ' },
33+ match ($ d ) { default => 'e ' } => 500
34+ };
35+
36+
37+ ?>
38+ --EXPECT--
39+ 100
40+ 300
41+ 500
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Match expression inside subject expression
3+ --FILE--
4+ <?php
5+
6+ echo match (match ('b ' ) { default => 'b ' }) {
7+ 'a ' => 100 ,
8+ 'b ' => 200 ,
9+ 'c ' => 300
10+ };
11+
12+ ?>
13+ --EXPECT--
14+ 200
You can’t perform that action at this time.
0 commit comments