Bug #65600 [Ver->Dup]: SplFileObject->next() not move next without current()
| From: | cmb@php.net | Date: | Mon, 16 May 2022 11:51:41 +0000 |
| Subject: | Bug #65600 [Ver->Dup]: SplFileObject->next() not move next without current() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-241525@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
+Status: Duplicate
Type: Bug
Package: SPL related
Operating System: *
PHP Version: 5.5.3
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
I'm closing this in favor of <https://github.com/php/php-src/issues/8562>.
Previous Comments:
------------------------------------------------------------------------
[2016-07-01 16:06:19] cmb@php.net
Forgot: see <https://3v4l.org/qM88J>.
------------------------------------------------------------------------
[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
------------------------------------------------------------------------
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