Add [#\ReturnTypeWillChange] attribute to TemporaryArrayObjectThrowingExceptions for PHP 8.3 compatibility

Created on 12 June 2023, over 1 year ago
Updated 14 June 2023, over 1 year ago

Problem/Motivation

There are some methods (sorting is one I faced) after https://github.com/php/php-src/pull/11200 (included in alpha1)

https://github.com/php/php-src/commit/85338569debd3f669ef5bc793822b2d9f3...

Steps to reproduce

$ php core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php
PHP Deprecated:  Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::asort($flags = Drupal\jsonapi\Normalizer\Value\SORT_REGULAR): bool should either be compatible with ArrayObject::asort(int $flags = SORT_REGULAR): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 40

Deprecated: Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::asort($flags = Drupal\jsonapi\Normalizer\Value\SORT_REGULAR): bool should either be compatible with ArrayObject::asort(int $flags = SORT_REGULAR): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 40
PHP Deprecated:  Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::ksort($flags = Drupal\jsonapi\Normalizer\Value\SORT_REGULAR): bool should either be compatible with ArrayObject::ksort(int $flags = SORT_REGULAR): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 144

Deprecated: Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::ksort($flags = Drupal\jsonapi\Normalizer\Value\SORT_REGULAR): bool should either be compatible with ArrayObject::ksort(int $flags = SORT_REGULAR): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 144
PHP Deprecated:  Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::uasort($callback): bool should either be compatible with ArrayObject::uasort(callable $callback): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 285

Deprecated: Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::uasort($callback): bool should either be compatible with ArrayObject::uasort(callable $callback): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 285
PHP Deprecated:  Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::uksort($callback): bool should either be compatible with ArrayObject::uksort(callable $callback): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 304

Deprecated: Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::uksort($callback): bool should either be compatible with ArrayObject::uksort(callable $callback): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 304
PHP Deprecated:  Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::natsort(): bool should either be compatible with ArrayObject::natsort(): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 172

Deprecated: Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::natsort(): bool should either be compatible with ArrayObject::natsort(): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 172
PHP Deprecated:  Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::natcasesort(): bool should either be compatible with ArrayObject::natcasesort(): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 158

Deprecated: Return type of Drupal\jsonapi\Normalizer\Value\TemporaryArrayObjectThrowingExceptions::natcasesort(): bool should either be compatible with ArrayObject::natcasesort(): true, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /var/www/html/web/core/modules/jsonapi/src/Normalizer/Value/TemporaryArrayObjectThrowingExceptions.php on line 158

Proposed resolution

Add [#\ReturnTypeWillChange] attribute to keep code compatible as we should keep compatibility with 8.1
PHP 8.2 added true return type https://wiki.php.net/rfc/true-type

Remaining tasks

- find all affected places
- patch, review and commit

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Fixed

Version

10.1 ✨

Component
JSON APIΒ  β†’

Last updated 3 days ago

Created by

πŸ‡«πŸ‡·France andypost

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

Comments & Activities

Production build 0.71.5 2024