bug75420.12.phpt 535 B

123456789101112131415161718192021
  1. --TEST--
  2. Bug #75420.12 (Indirect modification of magic method argument)
  3. --FILE--
  4. <?php
  5. class 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. $obj = new Test;
  12. $name = "foo";
  13. $name = str_repeat($name, 2);
  14. var_dump(empty($obj[$name]));
  15. var_dump($name);
  16. ?>
  17. --EXPECT--
  18. string(6) "foofoo"
  19. bool(false)
  20. int(24)