Bug #76852 [NEW]: IteratorIterator doesn't initialize without being rewound
| From: | morozov at tut dot by | Date: | Sat, 08 Sep 2018 22:04:33 +0000 |
| Subject: | Bug #76852 [NEW]: IteratorIterator doesn't initialize without being rewound | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-216936@lists.php.net to get a copy of this message | ||
From: morozov at tut dot by
Operating system: Linux
PHP version: 7.2.9
Package: SPL related
Bug Type: Bug
Bug description:IteratorIterator doesn't initialize without being rewound
Description:
------------
Right after construction, the state of IteratorIterator doesn't reflect
the state of the underlying iterator. Despite the fact that the
underlying iterator is valid and has non-empty values of key and value,
the wrapper is invalid and hass NULL values of key and value.
Test script:
---------------
$it = new ArrayIterator([1, 2, 3]);
var_dump($it->valid());
var_dump($it->key());
var_dump($it->current());
$it = new IteratorIterator($it);
var_dump($it->valid());
var_dump($it->key());
var_dump($it->current());
Expected result:
----------------
bool(true)
int(0)
int(1)
bool(true)
int(0)
int(1)
Actual result:
--------------
bool(true)
int(0)
int(1)
bool(false)
NULL
NULL
--
Edit bug report at https://bugs.php.net/bug.php?id=76852&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76852&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76852&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76852&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76852&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76852&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76852&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76852&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76852&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76852&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76852&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76852&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76852&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76852&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76852&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76852&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76852&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76852&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76852&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76852&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76852&r=mysqlcfg