php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80822 signature of ArrayObject::exchangeArray($array) has changed
Submitted: 2021-03-03 00:20 UTC Modified: 2021-11-11 14:26 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: ievgen dot varava at spryker dot com Assigned:
Status: Open Package: SPL related
PHP Version: 8.0.2 OS: OS X
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: ievgen dot varava at spryker dot com
New email:
PHP Version: OS:

 

 [2021-03-03 00:20 UTC] 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)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-03-03 00:37 UTC] 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-11-11 14:26 UTC] cmb@php.net
-Package: Documentation problem +Package: SPL related
 [2021-11-11 14:26 UTC] cmb@php.net
> 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>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 15:01:32 2024 UTC