xref: /PHP-8.2/ext/json/tests/bug81532.phpt (revision 6057cd23)
1--TEST--
2Bug #81532: Change of $depth behaviour in json_encode() on PHP 8.1
3--FILE--
4<?php
5
6// depth 1
7$a = new \stdClass();
8
9// depth 2
10$b = new \stdClass();
11$b->x = $a;
12
13// depth 3
14$c = new \stdClass();
15$c->x = [$a];
16
17var_export(json_encode($a, 0, 0)); echo "\n";
18var_export(json_encode($a, 0, 1)); echo "\n";
19var_export(json_encode($b, 0, 1)); echo "\n";
20var_export(json_encode($b, 0, 2)); echo "\n";
21var_export(json_encode($c, 0, 2)); echo "\n";
22var_export(json_encode($c, 0, 3)); echo "\n";
23
24?>
25--EXPECT--
26false
27'{}'
28false
29'{"x":{}}'
30false
31'{"x":[{}]}'
32