|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-08-21 06:50 UTC] foo at example dot com
Description: ------------ When seek()'ing beyond the end of file in an SplFileObject, SplFileObject::key() will return the number of the last line in the file but SplFileObject::current() will return false. This is inconsistent. Either SplFileObject::current() returns the content of the last line then, too. Or SplFileObject::key() should return false as well. As an alternative, SplFileObject::seek() could raise an OutOfBoundsException when trying to seek beyond EOF. Test script: --------------- $txt = <<< TXT foo bar baz TXT; $file = new SplTempFileObject(-1); $file->fwrite($txt); $file->seek(100); var_dump( $file->key(), $file->fgetcsv()); Expected result: ---------------- int(2) baz or false false or OutOfBoundsException Actual result: -------------- int(2) NULL PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 03:00:01 2025 UTC |
Sorry, the last line in the Test Script should read var_dump( $file->key(), $file->current() ); The problem does exist for fgetcsv() though, too. It will return NULL instead of the data at the last line.