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

From: Date: Tue, 24 Oct 2017 09:13:30 +0000
Subject: Doc #53926 [Opn->Asn]: LimitIterator::rewind() problem
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15160@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=53926&edit=1 ID: 53926 Updated by: salathe@php.net Reported by: maciej at maciej-kaczmarek dot pl Summary: LimitIterator::rewind() problem -Status: Open +Status: Assigned Type: Documentation Problem Package: SPL related Operating System: Irrelevant PHP Version: Irrelevant -Assigned To: +Assigned To: salathe Block user comment: N Private report: N New Comment: Re-assigning to me to keep visibility. Previous Comments: ------------------------------------------------------------------------ [2011-02-08 17:47:00] cataphract@php.net I'm posting this on pastebin due to some objections of the bug tracker: http://pastebin.com/S1wSfFh3 ------------------------------------------------------------------------ [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 https://bugs.php.net/bug.php?id=53926&edit=1

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