1--TEST-- 2json_encode() Recursion test with just JsonSerializable 3--FILE-- 4<?php 5 6class SerializingTest implements JsonSerializable 7{ 8 public $a = 1; 9 10 private $b = 'hide'; 11 12 protected $c = 'protect'; 13 14 public function jsonSerialize(): mixed 15 { 16 $result = json_encode($this); 17 var_dump($result); 18 return $this; 19 } 20} 21 22var_dump(json_encode(new SerializingTest())); 23?> 24--EXPECT-- 25bool(false) 26string(7) "{"a":1}" 27