|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63616 iterator_count loves SplFileObject too much (endless)
Submitted: 2012-11-26 21:43 UTC Modified: 2013-09-12 14:13 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: hanskrentel at yahoo dot de Assigned: helly (profile)
Status: Duplicate Package: SPL related
PHP Version: 5.4.9 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
2 + 44 = ?
Subscribe to this entry?

 [2012-11-26 21:43 UTC] hanskrentel at yahoo dot de
For some reason not clear to me, using iterator_count with the iterator interface 
of SplFileObject (as well with SplTempFileObject) results in an endless running 

Test script:
$test = new SplFileObject("data://text/plain,1\n2");
echo "Values: [", implode(', ', iterator_to_array($test)),
     "]\nCount: ", iterator_count($test), "\n";

-- OR --

$test = new SplTempFileObject();
echo "Values: [", implode(', ', iterator_to_array($test)),
     "]\nCount: ", iterator_count($test), "\n";

Expected result:
Values: [1, 2]
Count: 2

Actual result:
Values: [1, 2]


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-27 08:39 UTC]
helly, do you have time to look at this? seems memory stream doesn't handle the 
eof in this situation.

thanks ;)
 [2012-11-27 08:39 UTC]
-Assigned To: +Assigned To: helly
 [2013-09-12 14:13 UTC]
-Status: Assigned +Status: Duplicate
 [2013-09-12 14:13 UTC]
This has the same underlying issue as SplFileObject does not advance to the next line unless current() was called.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Jun 01 09:03:38 2023 UTC