3/13/2023 0 Comments Wordpress 5.9 releaseWordPress only contains one (test) class which implements the JsonSerializable interface and this commit fixes the issue for that class.Īs of PHP 8.1, the jsonSerialize() method in classes which implement the JsonSerializable interface are expected to have a return type declared. Or use the attribute, which is what this patch does.įor more details, see the discussion in the upstream PR: Ĭode Modernization: Fix " JsonSerializable_Object::jsonSerialize() should be compatible with JsonSerializable::jsonSerialize(): mixed" error on PHP 8.1.I'd strongly recommend against this as the interface is being implemented for a reason. So to fix this, there is basically a choice between two options: While attributes are a PHP 8.0+ feature, due to the choice of the # syntax, in PHP < 8.0, attributes will just be ignored and treated as comments, so there is no drawback to using the attribute. Luckily an attribute has been added to silence the deprecation warning. Return types in general were only introduced in PHP 7.0 and therefore cannot be used as WP has a minimum PHP version of 5.6.The mixed return type was only introduced in PHP 8.0 and therefore cannot be used as WP has a minimum PHP version of 5.6.This complies with the Liskov principle of covariance, which allows the return type of a child overloaded method to be more specific than that of the parent. The return type should be mixed or a more specific type. WP only contains one (test) class which implements the JsonSerializable interface and this patch fixes the issue for that class.īasically, as of PHP 8.1, the jsonSerialize() method in classes which implement the JsonSerializable interface are expected to have a return type declared. This relates to the Return types for internal methods RFC in PHP 8.1 and in particular, the change made in PHP PR #7051, which adds a mixed return type to the JsonSerializable::jsonSerialize() interface method. Some context for the patch I just uploaded: Also the doc blocks don't document null as an accepted value for the path. Ref: Screenshot at 11.10.49.png ( 314.6 KB) - added by spacedmonkey 9 months ago.ĥ3635-09-script-translations.patch ( 2.0 KB) - added by Chouby 9 months ago.Īvoid notices in untrailingslashit() due to the default value of script translations path being null instead of an empty string. Passing null causes a fwrite(): Passing null to parameter #2 ($data) of type string is deprecated notice. PHP 8.1 | Tests: fix bug in Tests_Admin_IncludesPlugin::test_get_plugin_files_folder() The Tests_Admin_IncludesPlugin::_create_plugin() expects the first parameter to be a text string to be written to a plugin file using fwrite(). ![]() PHP 8.1: WP_Sitemaps_Provider::get_sitemap_url(): fix deprecation noticeĥ3635-08-null-to-non-nullable-in-testcode.patch ( 1.4 KB) - added by jrf 12 months ago. ![]() as per the inline comment.ĥ3635-07-incorrect-default-value-for-http_build_query.patch ( 1.8 KB) - added by jrf 12 months ago. Pomo/ PHP 8.1: improve the fix for auto_detect_line_endings. ![]() PHP 8.1: Tests_Functions_DoEnclose: fix bug in testĥ3635-06-improve-auto_detect_line_endings-fix.patch ( 1.3 KB) - added by jrf 12 months ago. PHP 8.1/Tests: fix deprecation notice - another one for the "return type will change" seriesĥ3635-05-null-to-non-nullable-in-testcode.patch ( 1.8 KB) - added by jrf 13 months ago. , or the # attribute should be used to temporarily suppress the notice"ĥ3635-WP_Theme-arrayaccess.patch ( 1.7 KB) - added by jrf 13 months ago.įix various "Deprecated: Return type of WP_Theme::($offset) should either be compatible with ArrayAccess::(): type, or the # attribute should be used to temporarily suppress the notice"ĥ3635-tests-countable.patch ( 682 bytes) - added by jrf 13 months ago. 53635-jsonserialize.patch ( 847 bytes) - added by jrf 13 months ago.įix a "SomeClass::jsonSerialize() should be compatible with JsonSerializable::jsonSerialize(): mixed" errorĥ3635-WP_Hook-iterator-arrayaccess.patch ( 3.3 KB) - added by jrf 13 months ago.įix various "Deprecated: Return type of WP_Hook::() should either be compatible with.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |