Handle missing return type in __wakeup()

Created on 17 June 2024, 5 months ago
Updated 1 July 2024, 5 months ago

PHP Fatal error: Declaration of Drupal\search_api_opensearch\Plugin\search_api\backend\OpenSearchBackend::__sleep() must be compatible with Drupal\search_api\Backend\BackendPluginBase::__sleep(): array in /var/www/web/modules/contrib/search_api_opensearch/src/Plugin/search_api/backend/OpenSearchBackend.php on line 468

This is an issue because \Drupal\Core\DependencyInjection\DependencySerializationTrait::__sleep() and __wakeup() do not have return types in 10.2.x/10.3.x but they have been added in 11.x.

As PHP supports covariance, we can ensure our class implements the return types by overriding these methods and we can remove them when 10.x versions are no longer supported.

https://www.php.net/manual/en/language.oop5.variance.php

Adding return types should be done on the implementing classes first.

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany pebosi

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