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