1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/ext/json/tests/bug68992.phpt
2021-05-27 10:47:15 +02:00

26 lines
562 B
PHP

--TEST--
Bug #68992 (json_encode stacks exceptions thrown by JsonSerializable classes)
--FILE--
<?php
class MyClass implements JsonSerializable {
public function jsonSerialize(): mixed {
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]