}
if (intern->u.limit.offset < 0) {
php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
- zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be > 0", 0 TSRMLS_CC);
+ zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be >= 0", 0 TSRMLS_CC);
return NULL;
}
if (intern->u.limit.count < 0 && intern->u.limit.count != -1) {
--- /dev/null
+--TEST--
+SPL: LimitIterator zero is valid offset
+--FILE--
+<?php
+
+$array = array('a', 'b', 'c');
+$arrayIterator = new ArrayIterator($array);
+
+try {
+ $limitIterator = new LimitIterator($arrayIterator, 0);
+ foreach ($limitIterator as $item) {
+ echo $item . "\n";
+ }
+} catch (OutOfRangeException $e){
+ print $e->getMessage() . "\n";
+}
+
+try {
+ $limitIterator = new LimitIterator($arrayIterator, -1);
+ foreach ($limitIterator as $item) {
+ echo $item . "\n";
+ }
+} catch (OutOfRangeException $e){
+ print $e->getMessage() . "\n";
+}
+
+?>
+===DONE===
+--EXPECT--
+a
+b
+c
+Parameter offset must be >= 0
+===DONE===