xref: /PHP-8.0/ext/json/tests/bug72069.phpt (revision 32a1ebbd)
1--TEST--
2Bug #72069 (Behavior \JsonSerializable different from json_encode)
3--FILE--
4<?php
5
6$result = json_encode(['end' => json_decode(null, true)]);
7var_dump($result);
8
9class A implements \JsonSerializable
10{
11    function jsonSerialize()
12    {
13        return ['end' => json_decode(null, true)];
14    }
15}
16$a = new A();
17$toJsonData = $a->jsonSerialize();
18$result = json_encode($a);
19var_dump($result);
20
21$result = json_encode($toJsonData);
22var_dump($result);
23?>
24--EXPECT--
25string(12) "{"end":null}"
26string(12) "{"end":null}"
27string(12) "{"end":null}"
28