xref: /PHP-7.2/ext/json/tests/bug73113.phpt (revision 1ed4b13f)
1--TEST--
2Bug #73113 (Segfault with throwing JsonSerializable)
3Also 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
9class JsonSerializableObject implements \JsonSerializable
10{
11    public function jsonSerialize()
12    {
13        throw new \Exception('This error is expected');
14    }
15}
16
17$obj = new JsonSerializableObject();
18try {
19	echo json_encode($obj);
20} catch (\Exception $e) {
21	echo $e->getMessage();
22}
23--EXPECTF--
24This error is expected
25