bug68896.phpt 725 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. Bug #68896 (Changing ArrayObject value cause Segment Fault)
  3. --FILE--
  4. <?php
  5. class A implements ArrayAccess {
  6. private $a = [];
  7. function offsetGet($offset): mixed {
  8. return $this->a[$offset];
  9. }
  10. function offsetSet($offset, $value): void {
  11. $this->a[$offset] = $value;
  12. }
  13. function offsetExists($offset): bool {
  14. isset($this->a[$offset]);
  15. }
  16. function offsetUnset($offset): void {
  17. unset($this->a[$offset]);
  18. }
  19. }
  20. $obj = new ArrayObject(["a" => 1]);
  21. $obj["a"] .= "test";
  22. var_dump($obj["a"]);
  23. $obj = new A;
  24. $obj["a"] = 1;
  25. $obj["a"] .= "test";
  26. var_dump($obj["a"]);
  27. ?>
  28. --EXPECT--
  29. string(5) "1test"
  30. string(5) "1test"