xref: /PHP-8.3/Zend/tests/bug75474.phpt (revision 6b0f14fe)
1--TEST--
2Bug #75474: function scope static variables are not bound to a unique function
3--FILE--
4<?php
5
6function bar($k, $v) {
7    static $foo = [];
8    $foo[$k] = $v;
9    return $foo;
10}
11
12var_dump(bar(0, 0));
13var_dump(Closure::fromCallable("bar")(1, 1));
14var_dump(bar(2, 2));
15var_dump(Closure::fromCallable("bar")(3, 3));
16$RF = new ReflectionFunction("bar");
17var_dump($RF->getClosure()(4, 4));
18var_dump(bar(5, 5));
19
20?>
21--EXPECT--
22array(1) {
23  [0]=>
24  int(0)
25}
26array(2) {
27  [0]=>
28  int(0)
29  [1]=>
30  int(1)
31}
32array(3) {
33  [0]=>
34  int(0)
35  [1]=>
36  int(1)
37  [2]=>
38  int(2)
39}
40array(4) {
41  [0]=>
42  int(0)
43  [1]=>
44  int(1)
45  [2]=>
46  int(2)
47  [3]=>
48  int(3)
49}
50array(5) {
51  [0]=>
52  int(0)
53  [1]=>
54  int(1)
55  [2]=>
56  int(2)
57  [3]=>
58  int(3)
59  [4]=>
60  int(4)
61}
62array(6) {
63  [0]=>
64  int(0)
65  [1]=>
66  int(1)
67  [2]=>
68  int(2)
69  [3]=>
70  int(3)
71  [4]=>
72  int(4)
73  [5]=>
74  int(5)
75}
76