bug32252.phpt 754 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. Bug #32252 (Segfault when offsetSet throws an Exception (only without debug))
  3. --FILE--
  4. <?php
  5. class Test implements ArrayAccess
  6. {
  7. function offsetExists($offset): bool
  8. {
  9. echo __METHOD__ . "($offset)\n";
  10. return false;
  11. }
  12. function offsetGet($offset): mixed
  13. {
  14. echo __METHOD__ . "($offset)\n";
  15. return null;
  16. }
  17. function offsetSet($offset, $value): void
  18. {
  19. echo __METHOD__ . "($offset, $value)\n";
  20. throw new Exception("Ooops");
  21. }
  22. function offsetUnset($offset): void
  23. {
  24. echo __METHOD__ . "($offset)\n";
  25. }
  26. }
  27. $list = new Test();
  28. try
  29. {
  30. $list[-1] = 123;
  31. }
  32. catch (Exception $e)
  33. {
  34. echo "CAUGHT\n";
  35. }
  36. ?>
  37. --EXPECT--
  38. Test::offsetSet(-1, 123)
  39. CAUGHT