xref: /PHP-8.1/Zend/tests/list_self_assign.phpt (revision 2d48d734)
1--TEST--
2Test variable occurring on both LHS and RHS of list()
3--FILE--
4<?php
5
6$a = [1, 2, 3];
7list($a, $b, $c) = $a;
8var_dump($a, $b, $c);
9
10$b = [1, 2, 3];
11list($a, $b, $c) = $b;
12var_dump($a, $b, $c);
13
14$c = [1, 2, 3];
15list($a, $b, $c) = $c;
16var_dump($a, $b, $c);
17
18$a = [[1, 2], 3];
19list(list($a, $b), $c) = $a;
20var_dump($a, $b, $c);
21
22$b = [[1, 2], 3];
23list(list($a, $b), $c) = $b;
24var_dump($a, $b, $c);
25
26$b = [1, [2, 3]];
27list($a, list($b, $c)) = $b;
28var_dump($a, $b, $c);
29
30$c = [1, [2, 3]];
31list($a, list($b, $c)) = $c;
32var_dump($a, $b, $c);
33
34?>
35--EXPECT--
36int(1)
37int(2)
38int(3)
39int(1)
40int(2)
41int(3)
42int(1)
43int(2)
44int(3)
45int(1)
46int(2)
47int(3)
48int(1)
49int(2)
50int(3)
51int(1)
52int(2)
53int(3)
54int(1)
55int(2)
56int(3)
57