Edit report at https://bugs.php.net/bug.php?id=65600&edit=1
ID: 65600
User updated by: kentaro at ranvis dot com
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:
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.)
Previous Comments:
------------------------------------------------------------------------
[2013-09-01 11:49:58] [email protected]
Related To: Bug #65601
------------------------------------------------------------------------
[2013-09-01 11:49:16] [email protected]
Using the READ_AHEAD flag will enable the behavior you're expecting. I don't
know
if that requirement is intentional or necessary.
------------------------------------------------------------------------
[2013-09-01 10:09:37] kentaro at ranvis dot com
Description:
------------
SplFileObject->next() doesn't move to the next line unless ->current() is
called in advance.
Test script:
---------------
$f = new SplFileObject('php://memory', 'r+');
$f->fwrite("line 1\nline 2\nline 3");
$f->rewind();
assert('$f->current() === "line 1\n"');
$f->next();
assert('$f->current() === "line 2\n"');
$f->next();
var_dump($f->ftell()); // 14
assert('$f->current() === "line 3"');
$f->rewind();
$f->next();
$f->next();
var_dump($f->ftell()); // 0
assert('$f->current() === "line 3"'); // fails
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65600&edit=1