bug72069.phpt 550 B

123456789101112131415161718192021222324252627
  1. --TEST--
  2. Bug #72069 (Behavior \JsonSerializable different from json_encode)
  3. --FILE--
  4. <?php
  5. $result = json_encode(['end' => json_decode('', true)]);
  6. var_dump($result);
  7. class A implements \JsonSerializable
  8. {
  9. function jsonSerialize(): mixed
  10. {
  11. return ['end' => json_decode('', true)];
  12. }
  13. }
  14. $a = new A();
  15. $toJsonData = $a->jsonSerialize();
  16. $result = json_encode($a);
  17. var_dump($result);
  18. $result = json_encode($toJsonData);
  19. var_dump($result);
  20. ?>
  21. --EXPECT--
  22. string(12) "{"end":null}"
  23. string(12) "{"end":null}"
  24. string(12) "{"end":null}"