Bug #77903 [Opn]: ArrayIterator stops iterating after offsetSet call
| From: | gituser at yandex dot com | Date: | Tue, 16 Apr 2019 05:41:38 +0000 |
| Subject: | Bug #77903 [Opn]: ArrayIterator stops iterating after offsetSet call | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220472@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77903&edit=1
ID: 77903
User updated by: gituser at yandex dot com
Reported by: gituser at yandex dot com
Summary: ArrayIterator stops iterating after offsetSet call
Status: Open
Type: Bug
-Package: SPL_Types
+Package: SPL related
Operating System: Ubuntu 18.10 (64-bit)
PHP Version: 7.3.4
Block user comment: N
Private report: N
New Comment:
Hmm... Looks like SPL_Types https://www.php.net/manual/en/book.spl-types.php
which hasn't been updated for more than 5 years, isn't the same as SPL https://www.php.net/manual/en/book.spl.php
I think I found the correct category now.
Previous Comments:
------------------------------------------------------------------------
[2019-04-16 05:25:47] gituser at yandex dot com
Package -> SPL_Types
------------------------------------------------------------------------
[2019-04-15 18:52:30] gituser at yandex dot com
Description:
------------
i use fresh xampp for linux.
it looks like it works fine on earlier php versions e.g. 7.2. i.e. this is a regression.
i've tested on integer indices only. maybe on other data types the behavior differs, idk
sorry that i've posted a longer-than-20-lines test script, but when dealing with iterators, the
*sequence* of method calls is important, that's why so much lines needed. i've done my
best to keep the sample concise but it's still 30 lines long, sorry :(
another (longer) test sample: https://3v4l.org/Ft0Dh
Test script:
---------------
<?php
$a = new ArrayIterator();
$a->rewind();
var_dump($a->valid()); // false
var_dump($a->current()); // null
$a->offsetSet(1,1);
var_dump($a->valid()); // true
var_dump($a->current()); // 1
$a->next();
var_dump($a->valid()); // false
var_dump($a->current()); // null
$a->offsetSet(4,4);
var_dump($a->valid()); // true
var_dump($a->current()); // should: 4; got: undefined value of 'unknown' data type
$a->next();
var_dump($a->valid()); // should: false; got: true
var_dump($a->current()); // should: null; got: 4
$a->next();
var_dump($a->valid()); // false
var_dump($a->current()); // null
$a->offsetSet(2,2);
var_dump($a->valid()); // should: true; got: false
var_dump($a->current()); // should: 2; got: null
$a->next();
var_dump($a->valid()); // false
var_dump($a->current()); // null
$a->next();
var_dump($a->valid()); // false
var_dump($a->current()); // null
// it'll never return the "2"
Expected result:
----------------
has to be:
$i->valid() === false
$i->current() === null
$i->offsetSet(4,4)
$i->valid() === true
$i->current() === 4
see comments in test sample code for details
Actual result:
--------------
actually is: (the last line)
$i->current() === undefined value of unknown data type
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77903&edit=1