bug75420.13.phpt 495 B

1234567891011121314151617181920
  1. --TEST--
  2. Bug #75420.13 (Indirect modification of magic method argument)
  3. --FILE--
  4. <?php
  5. class Test implements ArrayAccess {
  6. public function offsetExists($x): bool { $GLOBALS["obj"] = 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. var_dump($obj[$name] ?? 12);
  14. var_dump($obj);
  15. ?>
  16. --EXPECT--
  17. string(3) "foo"
  18. int(42)
  19. int(24)