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
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3366288-2.patch | 2.84 KB | andypost |
Comments
Comment #2
andypostComment #3
andypostOther files are not affected, script to check
find core -name '*.php' -exec php -l {} \; >/dev/nullComment #4
andypostBaseline test runs
- 10.1 https://www.drupal.org/pift-ci-job/2691058
- 11.0 https://www.drupal.org/pift-ci-job/2691057
Comment #5
andypostOnly 2 tests failed comparing to 118 in base run
which means
&escaped twicethe same
Comment #6
longwaveLooks OK to me.
I did wonder if we should just change the return types here, and perhaps make the class final, but that can be done in a followup so we can discuss it.
edit: we can't make it final because something does extend it.
Comment #9
catchCommitted/pushed to 11.x and 10.1.x, thanks!
Comment #10
andypost@longwave Sadly we can't add
truetype hint as it was added in 8.2 https://wiki.php.net/rfc/true-typeComment #11
andypostExample of using
boolon 8.1Comment #12
andypostFiled follow-up for #6
Comment #13
andypostComment #14
andypostsorry
Comment #15
longwaveAhh thanks @andypost, I did not know that true was only PHP 8.2+.