bug73113.phpt 528 B

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