1--TEST--
2json_encode() Recursion test with JsonSerializable, __debugInfo and print_r
3--FILE--
4<?php
5
6class SerializingTest implements JsonSerializable
7{
8    public $a = 1;
9
10    public function __debugInfo()
11    {
12        return [ 'result' => $this->a ];
13    }
14
15    public function jsonSerialize(): mixed
16    {
17        print_r($this);
18        return $this;
19    }
20}
21
22var_dump(json_encode(new SerializingTest()));
23echo "---------\n";
24var_dump(new SerializingTest());
25
26?>
27--EXPECT--
28SerializingTest Object
29(
30    [result] => 1
31)
32string(7) "{"a":1}"
33---------
34object(SerializingTest)#1 (1) {
35  ["result"]=>
36  int(1)
37}
38