Missing Return Type for RenderableData::jsonSerialize()

Created on 10 October 2023, about 1 year ago
Updated 18 January 2024, 10 months ago

Problem/Motivation

For views with an exported array, the JSON output includes the following error:

Return type of Drupal\rest_views\RenderableData::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in <b>/var/www/html/web/modules/contrib/rest_views/src/RenderableData.php</b> on line <b>73</b><br />

In PHP 8.1 a tentative return type was added to the method: JsonSerializable::jsonSerialize()

Steps to reproduce

Create a view.
Add a field that will contain multiple rendered entities as an array
View the resulting output

Suggested Solution

Add #[\ReturnTypeWillChange] above line 73, or perhaps more ideally, change line 73 to read
public function jsonSerialize(): array {

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States the_double_a

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024