1<?php
2
3/* testSimpleAssignment */
4$a = false;
5
6/* testControlStructure */
7while(true) {}
8$a = 1;
9
10/* testClosureAssignment */
11$a = function($b=false;){};
12
13/* testHeredocFunctionArg */
14myFunction(<<<END
15Foo
16END
17, 'bar');
18
19/* testSwitch */
20switch ($a) {
21    case 1: {break;}
22    default: {break;}
23}
24
25/* testStatementAsArrayValue */
26$a = [new Datetime];
27$a = array(new Datetime);
28$a = new Datetime;
29
30/* testUseGroup */
31use Vendor\Package\{ClassA as A, ClassB, ClassC as C};
32
33$a = [
34    /* testArrowFunctionArrayValue */
35    'a' => fn() => return 1,
36    'b' => fn() => return 1,
37];
38
39/* testStaticArrowFunction */
40static fn ($a) => $a;
41
42/* testArrowFunctionReturnValue */
43fn(): array => [a($a, $b)];
44
45/* testArrowFunctionAsArgument */
46$foo = foo(
47    fn() => bar()
48);
49
50/* testArrowFunctionWithArrayAsArgument */
51$foo = foo(
52    fn() => [$row[0], $row[3]]
53);
54
55$match = match ($a) {
56    /* testMatchCase */
57    1 => 'foo',
58    /* testMatchDefault */
59    default => 'bar'
60};
61
62$match = match ($a) {
63    /* testMatchMultipleCase */
64    1, 2, => $a * $b,
65    /* testMatchDefaultComma */
66    default, => 'something'
67};
68
69match ($pressedKey) {
70    /* testMatchFunctionCall */
71    Key::RETURN_ => save($value, $user)
72};
73
74$result = match (true) {
75    /* testMatchFunctionCallArm */
76    str_contains($text, 'Welcome') || str_contains($text, 'Hello') => 'en',
77    str_contains($text, 'Bienvenue') || str_contains($text, 'Bonjour') => 'fr',
78    default => 'pl'
79};
80
81/* testMatchClosure */
82$result = match ($key) {
83    1 => function($a, $b) {},
84    2 => function($b, $c) {},
85};
86
87/* testMatchArray */
88$result = match ($key) {
89    1 => [1,2,3],
90    2 => [1 => one(), 2 => two()],
91};
92
93/* testNestedMatch */
94$result = match ($key) {
95    1 => match ($key) {
96        1 => 'one',
97        2 => 'two',
98    },
99    2 => match ($key) {
100        1 => 'two',
101        2 => 'one',
102    },
103};
104
105return 0;
106