xref: /PHP-8.1/Zend/tests/bug75420.10.phpt (revision 75a678a7)
1--TEST--
2Bug #75420.10 (Indirect modification of magic method argument)
3--FILE--
4<?php
5class Test implements ArrayAccess {
6    public function offsetExists($x): bool { $GLOBALS["name"] = 24; return true; }
7    public function offsetGet($x): mixed { var_dump($x); return 42; }
8    public function offsetSet($x, $y): void { }
9    public function offsetUnset($x): void { }
10}
11
12$obj = new Test;
13$name = "foo";
14$name = str_repeat($name, 2);
15var_dump($obj[$name] ?? 12);
16var_dump($name);
17?>
18--EXPECT--
19string(6) "foofoo"
20int(42)
21int(24)
22