Bug #65600 [Ver]: SplFileObject->next() not move next without current()
| From: | cmb@php.net | Date: | Fri, 01 Jul 2016 16:06:19 +0000 |
| Subject: | Bug #65600 [Ver]: SplFileObject->next() not move next without current() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-201970@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65600&edit=1
ID: 65600
Updated by: cmb@php.net
Reported by: kentaro at ranvis dot com
Summary: SplFileObject->next() not move next without
current()
Status: Verified
Type: Bug
Package: SPL related
Operating System: *
PHP Version: 5.5.3
Block user comment: N
Private report: N
New Comment:
Forgot: see <https://3v4l.org/qM88J>.
Previous Comments:
------------------------------------------------------------------------
[2016-07-01 15:48:44] cmb@php.net
Consider:
<?php
$f = new SplFileObject('php://temp', 'w+');
$f->fwrite("line 1\nline 2\nline 3");
$f->rewind();
$f->next();
$f->next();
$f->next();
var_dump($f->key());
var_dump($f->current());
While key() says we're at line 3, current() returns the first
line. That doesn't make sense; either key() should return 1, or
current() should return the third line.
------------------------------------------------------------------------
[2014-02-27 03:44:37] levim@php.net
Related To: Bug #65601
------------------------------------------------------------------------
[2013-09-01 14:46:48] kentaro at ranvis dot com
Thank you. It worked as expected with setFlags(SplFileObject::READ_AHEAD) before rewind().
I'll wait for further comment to see if this is a requirement (it seems to be.)
------------------------------------------------------------------------
[2013-09-01 11:49:58] requinix@php.net
Related To: Bug #65601
------------------------------------------------------------------------
[2013-09-01 11:49:16] requinix@php.net
Using the READ_AHEAD flag will enable the behavior you're expecting. I don't know
if that requirement is intentional or necessary.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=65600
--
Edit this bug report at https://bugs.php.net/bug.php?id=65600&edit=1