mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00

As it is, `::seek(0)` sets the file pointer to the beginning of the file, but `::seek($n)` where `$n > 0` sets the file pointer to the beginning of the following line, having line `$n` already read into the line buffer. This is pretty inconsistent; we fix it by always seeking to the beginning of the line. We also add a test case for the duplicate bug #46569. Closes GH-6434.
19 lines
294 B
PHP
19 lines
294 B
PHP
--TEST--
|
||
SPL: SplFileObject::getCurrentLine
|
||
--CREDITS--
|
||
H<EFBFBD>vard Eide <nucleuz at gmail.com>
|
||
#Testfest php.no
|
||
--FILE--
|
||
<?php
|
||
//line 2
|
||
//line 3
|
||
//line 4
|
||
//line 5
|
||
$s = new SplFileObject(__FILE__);
|
||
$s->seek(1);
|
||
echo $s->getCurrentLine();
|
||
echo $s->getCurrentLine();
|
||
?>
|
||
--EXPECT--
|
||
//line 2
|
||
//line 3
|