Bug #78356 [NEW]: Array returned from ArrayAccess is incorrectly unpacked as argument
| From: | esurov dot tsp at gmail dot com | Date: | Wed, 31 Jul 2019 10:56:39 +0000 |
| Subject: | Bug #78356 [NEW]: Array returned from ArrayAccess is incorrectly unpacked as argument | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222023@lists.php.net to get a copy of this message | ||
From: esurov dot tsp at gmail dot com
Operating system: Ubuntu
PHP version: 7.4Git-2019-07-31 (snap)
Package: SPL related
Bug Type: Bug
Bug description:Array returned from ArrayAccess is incorrectly unpacked as argument
Description:
------------
Let some object implements ArrayAccess and its offsetGet() returns an
array. Then if we use the accessed result as an unpacked (with ...
token) argument we're getting an error: Indirect modification of
overloaded element of class@anonymous has no effect.
Test script:
---------------
$object = new class implements ArrayAccess {
public function offsetGet($offset)
{
return [1, 2];
}
public function offsetExists($offset)
{
return true;
}
public function offsetUnset($offset) {}
public function offsetSet($offset, $value) {}
};
$x = max(...$object[0]);
Expected result:
----------------
$x contains 2.
Actual result:
--------------
Error: Indirect modification of overloaded element of class@anonymous
has no effect
--
Edit bug report at https://bugs.php.net/bug.php?id=78356&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78356&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78356&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78356&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78356&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78356&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78356&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78356&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78356&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78356&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78356&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78356&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78356&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78356&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78356&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78356&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78356&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78356&r=mysqlcfg