Doc #53926 [Opn]: LimitIterator::rewind() problem

From: Date: Tue, 08 Feb 2011 16:47:00 +0000
Subject: Doc #53926 [Opn]: LimitIterator::rewind() problem
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-5934@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=53926&edit=1 ID: 53926 Updated by: cataphract@php.net Reported by: maciej at maciej-kaczmarek dot pl Summary: LimitIterator::rewind() problem Status: Open Type: Documentation Problem Package: SPL related Operating System: Irrelevant PHP Version: Irrelevant Block user comment: N Private report: N New Comment: I'm posting this on pastebin due to some objections of the bug tracker: http://pastebin.com/S1wSfFh3 Previous Comments: ------------------------------------------------------------------------ [2011-02-04 18:47:47] maciej at maciej-kaczmarek dot pl Description: ------------ When you using LimitIterator with offset that is larger or equal than inner iterator collection size and you invoke rewind() on LimitIterator then you get out of bounds exception. You can solve that problem by handle exception from inner iterator's rewind() in LimitIterator::rewind() Test script: --------------- <?php $some_array = array('foo', 'bar'); $iter = new ArrayIterator($some_array); $limitIter = new LimitIterator($iter, 2); foreach($limitIter as $value) { echo $value; } echo 'OK'; ?> Expected result: ---------------- only 'OK' Actual result: -------------- PHP Fatal error: Uncaught exception 'OutOfBoundsException' with message 'Seek position 2 is out of range' in index.php:6 Stack trace: #0 [internal function]: ArrayIterator->seek(2) #1 index.php(6): LimitIterator->rewind() #2 {main} ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=53926&edit=1

« previous php.doc.bugs (#5934) next »