Annotation of embedaddon/php/ext/standard/tests/array/array_reduce_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_reduce() function : variation - object callbacks
3: --FILE--
4: <?php
5: /* Prototype : mixed array_reduce(array input, mixed callback [, int initial])
6: * Description: Iteratively reduce the array to a single value via the callback.
7: * Source code: ext/standard/array.c
8: * Alias to functions:
9: */
10:
11: echo "*** Testing array_reduce() : variation - object callbacks ***\n";
12:
13: class A {
14: static function adder($a, $b) {return $a + $b;}
15: public function adder2($a, $b) {return $a + $b;}
16: }
17:
18: $array = array(1);
19:
20: echo "\n--- Static method callback ---\n";
21: var_dump(array_reduce($array, array("A", "adder")));
22:
23: echo "\n--- Instance method callback ---\n";
24: var_dump(array_reduce($array, array(new A(), "adder2")));
25:
26: ?>
27: ===DONE===
28: --EXPECTF--
29: *** Testing array_reduce() : variation - object callbacks ***
30:
31: --- Static method callback ---
32: int(1)
33:
34: --- Instance method callback ---
35: int(1)
36: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>