Bug #78944 [Opn->Nab]: current() function on an empty custom ArrayIterator returns its properties

From: Date: Wed, 11 Dec 2019 11:03:08 +0000
Subject: Bug #78944 [Opn->Nab]: current() function on an empty custom ArrayIterator returns its properties
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224216@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78944&edit=1

 ID:                 78944
 Updated by:         requinix@php.net
 Reported by:        zoeslam at gmail dot com
 Summary:            current() function on an empty custom ArrayIterator
                     returns its properties
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            SPL related
 PHP Version:        7.4.0
 Block user comment: N
 Private report:     N

 New Comment:

See bug #77864


Previous Comments:
------------------------------------------------------------------------
[2019-12-11 10:54:27] zoeslam at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=78944&edit=1


Thread (2 messages)

« previous php.bugs (#224216) next »