tony2001                Tue Sep 19 09:35:28 2006 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/standard/tests/array   array_walk_objects.phpt 
                                        array_walk_rec_objects.phpt 

  Modified files:              
    /php-src/ext/standard       array.c 
    /php-src/ext/standard/tests/array   array_walk.phpt 
                                        array_walk_recursive1.phpt 
  Log:
  support objects in array_walk*()
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/array.c?r1=1.308.2.21.2.11&r2=1.308.2.21.2.12&diff_format=u
Index: php-src/ext/standard/array.c
diff -u php-src/ext/standard/array.c:1.308.2.21.2.11 
php-src/ext/standard/array.c:1.308.2.21.2.12
--- php-src/ext/standard/array.c:1.308.2.21.2.11        Tue Sep 19 09:04:15 2006
+++ php-src/ext/standard/array.c        Tue Sep 19 09:35:27 2006
@@ -21,7 +21,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: array.c,v 1.308.2.21.2.11 2006/09/19 09:04:15 tony2001 Exp $ */
+/* $Id: array.c,v 1.308.2.21.2.12 2006/09/19 09:35:27 tony2001 Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -1138,7 +1138,7 @@
        HashTable *target_hash;
 
        old_walk_func_name = BG(array_walk_func_name);
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "az|z", &array, 
&tmp, &userdata) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &array, 
&tmp, &userdata) == FAILURE) {
                return;
        }
        target_hash = HASH_OF(array);
@@ -1169,7 +1169,7 @@
        HashTable *target_hash;
 
        old_walk_func_name = BG(array_walk_func_name);
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "az|z", &array, 
&tmp, &userdata) == FAILURE) {
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz|z", &array, 
&tmp, &userdata) == FAILURE) {
                return;
        }
        target_hash = HASH_OF(array);
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_walk.phpt?r1=1.1.2.3&r2=1.1.2.4&diff_format=u
Index: php-src/ext/standard/tests/array/array_walk.phpt
diff -u php-src/ext/standard/tests/array/array_walk.phpt:1.1.2.3 
php-src/ext/standard/tests/array/array_walk.phpt:1.1.2.4
--- php-src/ext/standard/tests/array/array_walk.phpt:1.1.2.3    Tue Sep 19 
09:07:56 2006
+++ php-src/ext/standard/tests/array/array_walk.phpt    Tue Sep 19 09:35:27 2006
@@ -34,8 +34,8 @@
 Warning: array_walk() expects at least 2 parameters, 0 given in %s on line %d
 NULL
 
-Warning: array_walk() expects parameter 1 to be array, integer given in %s on 
line %d
-NULL
+Warning: array_walk(): The argument should be an array in %s on line %d
+bool(false)
 bool(true)
 int(1)
 int(0)
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_walk_recursive1.phpt?r1=1.1.2.3&r2=1.1.2.4&diff_format=u
Index: php-src/ext/standard/tests/array/array_walk_recursive1.phpt
diff -u php-src/ext/standard/tests/array/array_walk_recursive1.phpt:1.1.2.3 
php-src/ext/standard/tests/array/array_walk_recursive1.phpt:1.1.2.4
--- php-src/ext/standard/tests/array/array_walk_recursive1.phpt:1.1.2.3 Tue Sep 
19 09:07:56 2006
+++ php-src/ext/standard/tests/array/array_walk_recursive1.phpt Tue Sep 19 
09:35:27 2006
@@ -34,8 +34,8 @@
 Warning: array_walk_recursive() expects at least 2 parameters, 0 given in %s 
on line %d
 NULL
 
-Warning: array_walk_recursive() expects parameter 1 to be array, integer given 
in %s on line %d
-NULL
+Warning: array_walk_recursive(): The argument should be an array in %s on line 
%d
+bool(false)
 bool(true)
 int(1)
 int(0)

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_walk_objects.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_walk_objects.phpt
+++ php-src/ext/standard/tests/array/array_walk_objects.phpt
--TEST--
array_walk() and objects
--FILE--
<?php

function walk($key, $value) { 
        var_dump($value, $key); 
}

class test {
        private $var_pri = "test_private";
        protected $var_pro = "test_protected";
        public $var_pub = "test_public";
}

$stdclass = new stdclass;
$stdclass->foo = "foo";
$stdclass->bar = "bar";
array_walk($stdclass, "walk");

$t = new test;
array_walk($t, "walk");

$var = array();
array_walk($var, "walk");
$var = "";
array_walk($var, "walk");

echo "Done\n";
?>
--EXPECTF--     
string(3) "foo"
string(3) "foo"
string(3) "bar"
string(3) "bar"
string(13) "
string(12) "test_private"
string(10) "
string(14) "test_protected"
string(7) "var_pub"
string(11) "test_public"

Warning: array_walk(): The argument should be an array in %s on line %d
Done
--UEXPECTF--
unicode(3) "foo"
unicode(3) "foo"
unicode(3) "bar"
unicode(3) "bar"
unicode(13) "
unicode(12) "test_private"
unicode(10) "
unicode(14) "test_protected"
unicode(7) "var_pub"
unicode(11) "test_public"

Warning: array_walk(): The argument should be an array in %s on line %d
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/array/array_walk_rec_objects.phpt?view=markup&rev=1.1
Index: php-src/ext/standard/tests/array/array_walk_rec_objects.phpt
+++ php-src/ext/standard/tests/array/array_walk_rec_objects.phpt
--TEST--
array_walk_recursive() and objects
--FILE--
<?php

function walk($key, $value) { 
        var_dump($value, $key); 
}

class test {
        private $var_pri = "test_private";
        protected $var_pro = "test_protected";
        public $var_pub = "test_public";
}

$stdclass = new stdclass;
$stdclass->foo = "foo";
$stdclass->bar = "bar";
array_walk_recursive($stdclass, "walk");

$t = new test;
array_walk_recursive($t, "walk");

$var = array();
array_walk_recursive($var, "walk");
$var = "";
array_walk_recursive($var, "walk");

echo "Done\n";
?>
--EXPECTF--     
string(3) "foo"
string(3) "foo"
string(3) "bar"
string(3) "bar"
string(13) "
string(12) "test_private"
string(10) "
string(14) "test_protected"
string(7) "var_pub"
string(11) "test_public"

Warning: array_walk_recursive(): The argument should be an array in %s on line 
%d
Done
--UEXPECTF--
unicode(3) "foo"
unicode(3) "foo"
unicode(3) "bar"
unicode(3) "bar"
unicode(13) "
unicode(12) "test_private"
unicode(10) "
unicode(14) "test_protected"
unicode(7) "var_pub"
unicode(11) "test_public"

Warning: array_walk_recursive(): The argument should be an array in %s on line 
%d
Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to