Edit report at https://bugs.php.net/bug.php?id=63616&edit=1
ID: 63616 Updated by: ni...@php.net Reported by: hanskrentel at yahoo dot de Summary: iterator_count loves SplFileObject too much (endless) -Status: Assigned +Status: Duplicate Type: Bug Package: SPL related Operating System: Windows PHP Version: 5.4.9 Assigned To: helly Block user comment: N Private report: N New Comment: This has the same underlying issue as https://bugs.php.net/bug.php?id=65600. SplFileObject does not advance to the next line unless current() was called. Previous Comments: ------------------------------------------------------------------------ [2012-11-27 08:39:01] larue...@php.net helly, do you have time to look at this? seems memory stream doesn't handle the eof in this situation. thanks ;) ------------------------------------------------------------------------ [2012-11-26 21:43:27] hanskrentel at yahoo dot de Description: ------------ 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 script. Test script: --------------- <?php $test = new SplFileObject("data://text/plain,1\n2"); $test->setFlags(SplFileObject::DROP_NEW_LINE); echo "Values: [", implode(', ', iterator_to_array($test)), "]\nCount: ", iterator_count($test), "\n"; ?> -- OR -- <?php $test = new SplTempFileObject(); $test->setFlags(SplTempFileObject::DROP_NEW_LINE); $test->fwrite("1\n2"); echo "Values: [", implode(', ', iterator_to_array($test)), "]\nCount: ", iterator_count($test), "\n"; ?> Expected result: ---------------- Values: [1, 2] Count: 2 Actual result: -------------- Values: [1, 2] Count: ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63616&edit=1