bug81532.phpt 558 B

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