Annotation of embedaddon/php/ext/standard/tests/array/array_walk_object1.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_walk() function : object functionality
3: --FILE--
4: <?php
5: /* Prototype : bool array_walk(array $input, string $funcname [, mixed $userdata])
6: * Description: Apply a user function to every member of an array
7: * Source code: ext/standard/array.c
8: */
9:
10: /*
11: * Pasing object in place of 'input' argument to test object functionatlity
12: */
13:
14: echo "*** Testing array_walk() : object functionality ***\n";
15:
16: /*
17: * Prototype : callback(mixed $value, mixed $key, int $addvalue
18: * Parameters : $value - values in given input array
19: * $key - keys in given input array
20: * $addvalue - value to be added
21: * Description : Function adds the addvalue to each element of an array
22: */
23:
24: function callback($value, $key, $user_data)
25: {
26: var_dump($key);
27: var_dump($value);
28: var_dump($user_data);
29: echo "\n";
30: }
31:
32: class MyClass
33: {
34: private $pri_value;
35: public $pub_value;
36: protected $pro_value;
37: public function __construct($setVal)
38: {
39: $this->pri_value = $setVal;
40: $this->pub_value = $setVal;
41: $this->pro_value = $setVal;
42: }
43: };
44:
45: // object for 'input' argument
46: $input = new MyClass(10);
47:
48: var_dump( array_walk($input, "callback", 1));
49:
50: echo "Done"
51: ?>
52: --EXPECTF--
53: *** Testing array_walk() : object functionality ***
54: %unicode|string%(18) "%r\0%rMyClass%r\0%rpri_value"
55: int(10)
56: int(1)
57:
58: %unicode|string%(9) "pub_value"
59: int(10)
60: int(1)
61:
62: %unicode|string%(12) "%r\0%r*%r\0%rpro_value"
63: int(10)
64: int(1)
65:
66: bool(true)
67: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>