Doc #80822 [Opn]: signature of ArrayObject::exchangeArray($array) has changed
[email protected] Thu, 11 Nov 2021 14:26:41 +0000
| Newsgroups | php.doc.bugs |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://bugs.php.net/bug.php?id=80822&edit=1 ID: 80822 Updated by: [email protected] Reported by: ievgen dot varava at spryker dot com Summary: signature of ArrayObject::exchangeArray($array) has changed Status: Open Type: Documentation Problem -Package: Documentation problem +Package: SPL related Operating System: OS X PHP Version: 8.0.2 Block user comment: N Private report: N New Comment: > Signature of ArrayObject::exchangeArray($array) has changed, but > is not documented. That's a bit tricky. The method always expected array|object (and the documentation reflects that now), but prior to PHP 8.0.0, the arginfo (which is relevant for inheritance) had no info about the parameter type. This likely affects a lot of other methods as well. > Also, passing invalid parameter throws TypeError in PHP8 vs > InvalidArgumentException in PHP7 Passing invalid parameter types to internal functions is documented to be undefined behavior[1], so we may not want to document this change. [1] <https://www.php.net/manual/en/functions.internal.php> Previous Comments: ------------------------------------------------------------------------ [2021-03-03 00:37:47] ievgen dot varava at spryker dot com Also, passing invalid parameter throws TypeError in PHP8 vs InvalidArgumentException in PHP7 <?php $a = new ArrayObject(); $a->exchangeArray(123); ?> ------------------------------------------------------------------------ [2021-03-03 00:20:04] ievgen dot varava at spryker dot com Description: ------------ --- From manual page: https://php.net/arrayobject.exchangearray --- Signature of ArrayObject::exchangeArray($array) has changed, but is not documented. Some code that worked in php7 might become incompatible with php8 Test script: --------------- <?php interface intA { public function exchangeArray($param); } class classB extends ArrayObject implements intA {} ?> Expected result: ---------------- no errors (works in php 7.4.13) Actual result: -------------- Fatal error: Declaration of ArrayObject::exchangeArray(object|array $array) must be compatible with intA::exchangeArray($param) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80822&edit=1