Req #79972 [NEW]: Implement JsonSerializable interface in stdClass

From: Date: Thu, 13 Aug 2020 13:15:41 +0000
Subject: Req #79972 [NEW]: Implement JsonSerializable interface in stdClass
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228574@lists.php.net to get a copy of this message
From: fodor dot laszlo at gmail dot com Operating system: PHP version: 7.4.9 Package: Class/Object related Bug Type: Feature/Change Request Bug description:Implement JsonSerializable interface in stdClass Description: ------------ It would be great if stdClass would implement JsonSerializable for multiple reasons. First of all, since the interface has been introduced a lot of methods are expecting JsonSerializable as a parameter to work with by type-hinting the parameter. And sometimes these methods should work properly with an array as well. If stdClass would implement JsonSerializable interface a simple (object) casting would be enough to pass an array to such method. Another reason is testing. Currently I need to set up a Mock object to test a method what expects a JsonSerializable. Instead I could just use a simple stdClass with some dummy data in it -- Edit bug report at https://bugs.php.net/bug.php?id=79972&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79972&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79972&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79972&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79972&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79972&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79972&r=support Expected behavior: https://bugs.php.net/fix.php?id=79972&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79972&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79972&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79972&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79972&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79972&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79972&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79972&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79972&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79972&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79972&r=mysqlcfg

« previous php.bugs (#228574) next »