Skip to content

PHP8 Compatibility: Annotate return types for jsonSerialize() implementations#106

Open
dmf-janw wants to merge 1 commit intodoofinder:masterfrom
dmf-janw:php81-json-return-type-fix
Open

PHP8 Compatibility: Annotate return types for jsonSerialize() implementations#106
dmf-janw wants to merge 1 commit intodoofinder:masterfrom
dmf-janw:php81-json-return-type-fix

Conversation

@dmf-janw
Copy link

@dmf-janw dmf-janw commented Dec 6, 2023

Starting with PHP 8, it is required to annotate the return type of jsonSerialize() methods for objects that implement \JsonSerializable.

Without this, one would run into the following fatal error (for example):

PHP Fatal error:  During inheritance of JsonSerializable: Uncaught Exception: Deprecated Functionality: Return type of Doofinder\Management\Model\Item::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in vendor/doofinder/doofinder/src/Management/Model/Item.php on line 91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant