summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
authorPeter Cowburn <salathe@php.net>2010-02-22 23:55:30 +0000
committerPeter Cowburn <salathe@php.net>2010-02-22 23:55:30 +0000
commitfbbe3e3686b4abe71982106d5ca2dde895ec8fdf (patch)
tree906c326f1281a67003532d5b697009d769ef193e /ext/spl
parente8be6063676fc3f4a2978fab2612e55480e8a890 (diff)
downloadphp-git-fbbe3e3686b4abe71982106d5ca2dde895ec8fdf.tar.gz
Corrected typo in LimitIterator offset exception. Fixes #51119
Diffstat (limited to 'ext/spl')
-rwxr-xr-xext/spl/spl_iterators.c2
-rw-r--r--ext/spl/tests/bug51119.phpt34
-rw-r--r--ext/spl/tests/spl_limit_iterator_check_limits.phpt2
3 files changed, 36 insertions, 2 deletions
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index 025c573e07..0b0acc3e78 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -1272,7 +1272,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
index 0000000000..441aa1280a
--- /dev/null
+++ b/ext/spl/tests/bug51119.phpt
@@ -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===
diff --git a/ext/spl/tests/spl_limit_iterator_check_limits.phpt b/ext/spl/tests/spl_limit_iterator_check_limits.phpt
index 01436a8fbe..ae1bc85e89 100644
--- a/ext/spl/tests/spl_limit_iterator_check_limits.phpt
+++ b/ext/spl/tests/spl_limit_iterator_check_limits.phpt
@@ -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===