mirror of
https://github.com/php/php-src.git
synced 2024-12-16 05:15:03 +08:00
75a678a7e3
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
97 lines
1.4 KiB
PHP
97 lines
1.4 KiB
PHP
--TEST--
|
|
Bug #31683 (changes to $name in __get($name) override future parameters)
|
|
--FILE--
|
|
<?php
|
|
|
|
class Foo implements ArrayAccess {
|
|
|
|
function __get($test) {
|
|
var_dump($test);
|
|
$test = 'bug';
|
|
}
|
|
|
|
function __set($test, $val) {
|
|
var_dump($test);
|
|
var_dump($val);
|
|
$test = 'bug';
|
|
$val = 'bug';
|
|
}
|
|
|
|
function __call($test, $arg) {
|
|
var_dump($test);
|
|
$test = 'bug';
|
|
}
|
|
|
|
function offsetget($test): mixed {
|
|
var_dump($test);
|
|
$test = 'bug';
|
|
return 123;
|
|
}
|
|
|
|
function offsetset($test, $val): void {
|
|
var_dump($test);
|
|
var_dump($val);
|
|
$test = 'bug';
|
|
$val = 'bug';
|
|
}
|
|
|
|
function offsetexists($test): bool {
|
|
var_dump($test);
|
|
$test = 'bug';
|
|
return true;
|
|
}
|
|
|
|
function offsetunset($test): void {
|
|
var_dump($test);
|
|
$test = 'bug';
|
|
}
|
|
|
|
}
|
|
|
|
$foo = new Foo();
|
|
$a = "ok";
|
|
|
|
for ($i=0; $i < 2; $i++) {
|
|
$foo->ok("ok");
|
|
$foo->ok;
|
|
$foo->ok = "ok";
|
|
$x = $foo["ok"];
|
|
$foo["ok"] = "ok";
|
|
isset($foo["ok"]);
|
|
unset($foo["ok"]);
|
|
// $foo[];
|
|
$foo[] = "ok";
|
|
// isset($foo[]);
|
|
// unset($foo[]);
|
|
$foo->$a;
|
|
echo "---\n";
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
NULL
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
---
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
NULL
|
|
string(2) "ok"
|
|
string(2) "ok"
|
|
---
|