bug68992.phpt 562 B

12345678910111213141516171819202122232425
  1. --TEST--
  2. Bug #68992 (json_encode stacks exceptions thrown by JsonSerializable classes)
  3. --FILE--
  4. <?php
  5. class MyClass implements JsonSerializable {
  6. public function jsonSerialize(): mixed {
  7. throw new Exception('Not implemented!');
  8. }
  9. }
  10. $classes = [];
  11. for($i = 0; $i < 5; $i++) {
  12. $classes[] = new MyClass();
  13. }
  14. try {
  15. json_encode($classes);
  16. } catch(Exception $e) {
  17. do {
  18. printf("%s (%d) [%s]\n", $e->getMessage(), $e->getCode(), get_class($e));
  19. } while ($e = $e->getPrevious());
  20. }
  21. ?>
  22. --EXPECT--
  23. Not implemented! (0) [Exception]