Bug #63616 [Opn]: iterator_count loves SplFileObject too much (endless)
| From: | laruence@php.net | Date: | Tue, 27 Nov 2012 08:39:01 +0000 |
| Subject: | Bug #63616 [Opn]: iterator_count loves SplFileObject too much (endless) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-174958@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63616&edit=1
ID: 63616
Updated by: laruence@php.net
Reported by: hanskrentel at yahoo dot de
Summary: iterator_count loves SplFileObject too much
(endless)
Status: Open
Type: Bug
Package: SPL related
Operating System: Windows
PHP Version: 5.4.9
-Assigned To:
+Assigned To: helly
Block user comment: N
Private report: N
New Comment:
helly, do you have time to look at this? seems memory stream doesn't handle the
eof in this situation.
thanks ;)
Previous Comments:
------------------------------------------------------------------------
[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