Bug #78944 [NEW]: current() function on an empty custom ArrayIterator returns its properties
From: zoeslam at gmail dot com
Operating system:
PHP version: 7.4.0
Package: SPL related
Bug Type: Bug
Bug description:current() function on an empty custom ArrayIterator returns its properties
Description:
------------
Calling current() function on an empty custom ArrayIterator returns its
properties.
https://3v4l.org/4MTF2
Bug present from PHP 7.4, prior versions are not affected
Test script:
---------------
class MyArrayIterator extends \ArrayIterator
{
private $foo = 'bar';
}
$ai = new MyArrayIterator([]);
var_dump(count($ai));
var_dump($ai->current());
var_dump(current($ai));
Expected result:
----------------
int(0)
NULL
bool(false)
Actual result:
--------------
int(0)
NULL
string(3) "bar"
--
Edit bug report at https://bugs.php.net/bug.php?id=78944&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78944&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78944&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78944&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78944&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78944&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78944&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78944&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78944&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78944&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78944&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78944&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78944&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78944&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78944&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78944&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78944&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78944&r=mysqlcfg
Thread (2 messages)
- zoeslam at gmail dot com