bug73113.phpt 478 B

1234567891011121314151617181920212223
  1. --TEST--
  2. Bug #73113 (Segfault with throwing JsonSerializable)
  3. Also test that the custom exception is not wrapped by ext/json
  4. --FILE--
  5. <?php
  6. class JsonSerializableObject implements \JsonSerializable
  7. {
  8. public function jsonSerialize(): mixed
  9. {
  10. throw new \Exception('This error is expected');
  11. }
  12. }
  13. $obj = new JsonSerializableObject();
  14. try {
  15. echo json_encode($obj);
  16. } catch (\Exception $e) {
  17. echo $e->getMessage();
  18. }
  19. ?>
  20. --EXPECT--
  21. This error is expected