]> granicus.if.org Git - php/commitdiff
Corrected typo in LimitIterator offset exception. Fixes #51119
authorPeter Cowburn <salathe@php.net>
Mon, 22 Feb 2010 23:55:30 +0000 (23:55 +0000)
committerPeter Cowburn <salathe@php.net>
Mon, 22 Feb 2010 23:55:30 +0000 (23:55 +0000)
ext/spl/spl_iterators.c
ext/spl/tests/bug51119.phpt [new file with mode: 0644]
ext/spl/tests/spl_limit_iterator_check_limits.phpt

index 81f73cfff11105edd7945c8186e6b50b0fc81d36..a49a6f46c0fad8b6c662e45e3841baf5279549c4 100755 (executable)
@@ -1321,7 +1321,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
                                return NULL;
                        }
                        if (intern->u.limit.offset < 0) {
-                               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);
                                zend_restore_error_handling(&error_handling TSRMLS_CC);
                                return NULL;
                        }
diff --git a/ext/spl/tests/bug51119.phpt b/ext/spl/tests/bug51119.phpt
new file mode 100644 (file)
index 0000000..441aa12
--- /dev/null
@@ -0,0 +1,34 @@
+--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===
index 01436a8fbe01de882142540aba90f6922323acc5..ae1bc85e895e07fac165c02bfd46b165a067f9c8 100644 (file)
@@ -32,6 +32,6 @@ try {
 ?>
 ===DONE===
 --EXPECTF--
-Parameter offset must be > 0
+Parameter offset must be >= 0
 Parameter count must either be -1 or a value greater than or equal 0
 ===DONE===