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