xref: /PHP-8.0/ext/spl/tests/gh8273.phpt (revision 6186ecd4)
1--TEST--
2GH-8273 (SplFileObject: key() returns wrong value)
3--FILE--
4<?php
5
6$file = new SplTempFileObject();
7
8// write to file
9for ($i = 0; $i < 5; $i++) {
10    $file->fwrite("line {$i}" . PHP_EOL);
11}
12
13// read from file
14$file->rewind();
15while ($file->valid()) {
16    echo $file->key(), ': ', $file->fgets();
17}
18?>
19--EXPECT--
200: line 0
211: line 1
222: line 2
233: line 3
244: line 4
25