summaryrefslogtreecommitdiff
path: root/ext/json/tests/bug68992.phpt
blob: 06448bbb38330406a3c5f015dee303dc746b6e4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
--TEST--
Bug #68992 (json_encode stacks exceptions thrown by JsonSerializable classes)
--SKIPIF--
<?php
if (!extension_loaded('json')) die('skip');
?>
--FILE--
<?php

class MyClass implements JsonSerializable {
    public function jsonSerialize() {
	    throw new Exception('Not implemented!');
	}
}
$classes = [];
for($i = 0; $i < 5; $i++) {
    $classes[] = new MyClass();
}

try {
    json_encode($classes);
} catch(Exception $e) {
    do {
	    printf("%s (%d) [%s]\n", $e->getMessage(), $e->getCode(), get_class($e));
	} while ($e = $e->getPrevious());
}
?>
--EXPECT--
Not implemented! (0) [Exception]