xref: /PHP-7.2/Zend/tests/bug31683.phpt (revision 17ccbeec)
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) {
26    var_dump($test);
27    $test = 'bug';
28    return 123;
29  }
30
31  function offsetset($test, $val) {
32    var_dump($test);
33    var_dump($val);
34    $test = 'bug';
35    $val  = 'bug';
36  }
37
38  function offsetexists($test) {
39    var_dump($test);
40    $test = 'bug';
41  }
42
43  function offsetunset($test) {
44    var_dump($test);
45    $test = 'bug';
46  }
47
48}
49
50$foo = new Foo();
51$a = "ok";
52
53for ($i=0; $i < 2; $i++) {
54  $foo->ok("ok");
55  $foo->ok;
56  $foo->ok = "ok";
57  $x = $foo["ok"];
58  $foo["ok"] = "ok";
59  isset($foo["ok"]);
60  unset($foo["ok"]);
61//  $foo[];
62  $foo[] = "ok";
63//  isset($foo[]);
64//  unset($foo[]);
65  $foo->$a;
66  echo "---\n";
67}
68?>
69--EXPECT--
70string(2) "ok"
71string(2) "ok"
72string(2) "ok"
73string(2) "ok"
74string(2) "ok"
75string(2) "ok"
76string(2) "ok"
77string(2) "ok"
78string(2) "ok"
79NULL
80string(2) "ok"
81string(2) "ok"
82---
83string(2) "ok"
84string(2) "ok"
85string(2) "ok"
86string(2) "ok"
87string(2) "ok"
88string(2) "ok"
89string(2) "ok"
90string(2) "ok"
91string(2) "ok"
92NULL
93string(2) "ok"
94string(2) "ok"
95---
96