helly Fri May 26 01:40:57 2006 UTC
Added files:
/php-src/ext/spl/tests spl_004.phpt
Modified files:
/php-src/ext/spl php_spl.c spl_iterators.c
Log:
- Fix handling of third parameter to iterator_apply()
- Add test
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/php_spl.c?r1=1.92&r2=1.93&diff_format=u
Index: php-src/ext/spl/php_spl.c
diff -u php-src/ext/spl/php_spl.c:1.92 php-src/ext/spl/php_spl.c:1.93
--- php-src/ext/spl/php_spl.c:1.92 Fri May 26 00:49:02 2006
+++ php-src/ext/spl/php_spl.c Fri May 26 01:40:57 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_spl.c,v 1.92 2006/05/26 00:49:02 helly Exp $ */
+/* $Id: php_spl.c,v 1.93 2006/05/26 01:40:57 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -628,7 +628,7 @@
ZEND_BEGIN_ARG_INFO_EX(arginfo_iterator_apply, 0, 0, 2)
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
ZEND_ARG_INFO(0, function)
- ZEND_ARG_ARRAY_INFO(0, args, 0)
+ ZEND_ARG_ARRAY_INFO(0, args, 1)
ZEND_END_ARG_INFO();
/* {{{ spl_functions
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/spl_iterators.c?r1=1.135&r2=1.136&diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.135
php-src/ext/spl/spl_iterators.c:1.136
--- php-src/ext/spl/spl_iterators.c:1.135 Fri May 26 00:37:33 2006
+++ php-src/ext/spl/spl_iterators.c Fri May 26 01:40:57 2006
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_iterators.c,v 1.135 2006/05/26 00:37:33 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.136 2006/05/26 01:40:57 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -2682,8 +2682,9 @@
{
spl_iterator_apply_info apply_info;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Of|a",
&apply_info.obj, zend_ce_traversable, &apply_info.fci, &apply_info.fcc,
&apply_info.args) == FAILURE) {
- RETURN_FALSE;
+ apply_info.args = NULL;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Of|a!",
&apply_info.obj, zend_ce_traversable, &apply_info.fci, &apply_info.fcc,
&apply_info.args) == FAILURE) {
+ return;
}
apply_info.count = 0;
http://cvs.php.net/viewcvs.cgi/php-src/ext/spl/tests/spl_004.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/spl_004.phpt
+++ php-src/ext/spl/tests/spl_004.phpt
--TEST--
SPL: iterator_apply()
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php
function my_error_handler($errno, $errstr, $errfile, $errline) {
echo "Error: $errstr\n";
}
set_error_handler('my_error_handler');
function test_arg($arg)
{
if ($arg instanceof Iterator)
{
var_dump($arg->key());
var_dump($arg->current());
}
else
{
var_dump($arg);
}
return true;
}
function test()
{
static $arg = 0;
var_dump($arg++);
return true;
}
$it = new RecursiveArrayIterator(array(1, array(21, 22), 3));
var_dump(iterator_apply($it, 'test', NULL));
echo "===ARGS===\n";
var_dump(iterator_apply($it, 'test_arg', array($it)));
echo "===RECURSIVE===\n";
$it = new RecursiveIteratorIterator($it);
var_dump(iterator_apply($it, 'test'));
echo "===ERRORS===\n";
var_dump(iterator_apply($it, 'test', 1));
var_dump(iterator_apply($it, 'non_existing_functon'));
var_dump(iterator_apply($it, 'non_existing_functon', NULL, 2));
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
int(0)
int(1)
int(2)
int(3)
===ARGS===
int(0)
int(1)
int(1)
array(2) {
[0]=>
int(21)
[1]=>
int(22)
}
int(2)
int(3)
int(3)
===RECURSIVE===
int(3)
int(4)
int(5)
int(6)
int(4)
===ERRORS===
Error: Argument 3 passed to iterator_apply() must be an array, integer given
Error: iterator_apply() expects parameter 3 to be array, integer given
NULL
Error: iterator_apply() expects parameter 2 to be function,%sstring given
NULL
Error: iterator_apply() expects at most 3 parameters, 4 given
NULL
===DONE===
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php