source: src/router/php7/ext/json/tests/bug68992.phpt @ 31874

Last change on this file since 31874 was 31874, checked in by brainslayer, 3 months ago

update php

File size: 607 bytes
Line 
1--TEST--
2Bug #68992 (json_encode stacks exceptions thrown by JsonSerializable classes)
3--SKIPIF--
4<?php
5if (!extension_loaded('json')) die('skip');
6?>
7--FILE--
8<?php
9
10class MyClass implements JsonSerializable {
11    public function jsonSerialize() {
12            throw new Exception('Not implemented!');
13        }
14}
15$classes = [];
16for($i = 0; $i < 5; $i++) {
17    $classes[] = new MyClass();
18}
19
20try {
21    json_encode($classes);
22} catch(Exception $e) {
23    do {
24            printf("%s (%d) [%s]\n", $e->getMessage(), $e->getCode(), get_class($e));
25        } while ($e = $e->getPrevious());
26}
27?>
28--EXPECT--
29Not implemented! (0) [Exception]
Note: See TracBrowser for help on using the repository browser.