xref: /PHP-8.2/Zend/tests/bug31683.phpt (revision 75a678a7)
1--TEST--
2Bug #31683 (changes to $name in __get($name) override future parameters)
3--FILE--
4<?php
5
6class Foo implements ArrayAccess {
7
8  function __get($test) {
9    var_dump($test);
10    $test = 'bug';
11  }
12
13  function __set($test, $val) {
14    var_dump($test);
15    var_dump($val);
16    $test = 'bug';
17    $val = 'bug';
18  }
19
20  function __call($test, $arg) {
21    var_dump($test);
22    $test = 'bug';
23  }
24
25  function offsetget($test): mixed {
26    var_dump($test);
27    $test = 'bug';
28    return 123;
29  }
30
31  function offsetset($test, $val): void {
32    var_dump($test);
33    var_dump($val);
34    $test = 'bug';
35    $val  = 'bug';
36  }
37
38  function offsetexists($test): bool {
39    var_dump($test);
40    $test = 'bug';
41    return true;
42  }
43
44  function offsetunset($test): void {
45    var_dump($test);
46    $test = 'bug';
47  }
48
49}
50
51$foo = new Foo();
52$a = "ok";
53
54for ($i=0; $i < 2; $i++) {
55  $foo->ok("ok");
56  $foo->ok;
57  $foo->ok = "ok";
58  $x = $foo["ok"];
59  $foo["ok"] = "ok";
60  isset($foo["ok"]);
61  unset($foo["ok"]);
62//  $foo[];
63  $foo[] = "ok";
64//  isset($foo[]);
65//  unset($foo[]);
66  $foo->$a;
67  echo "---\n";
68}
69?>
70--EXPECT--
71string(2) "ok"
72string(2) "ok"
73string(2) "ok"
74string(2) "ok"
75string(2) "ok"
76string(2) "ok"
77string(2) "ok"
78string(2) "ok"
79string(2) "ok"
80NULL
81string(2) "ok"
82string(2) "ok"
83---
84string(2) "ok"
85string(2) "ok"
86string(2) "ok"
87string(2) "ok"
88string(2) "ok"
89string(2) "ok"
90string(2) "ok"
91string(2) "ok"
92string(2) "ok"
93NULL
94string(2) "ok"
95string(2) "ok"
96---
97