1--TEST--
2Test 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
14echo "*** 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
24function callback($value, $key, $user_data)
25{
26  var_dump($key);
27  var_dump($value);
28  var_dump($user_data);
29  echo "\n";
30}
31
32class 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
48var_dump( array_walk($input, "callback", 1));
49
50echo "Done"
51?>
52--EXPECTF--
53*** Testing array_walk() : object functionality ***
54%unicode|string%(18) "%r\0%rMyClass%r\0%rpri_value"
55int(10)
56int(1)
57
58%unicode|string%(9) "pub_value"
59int(10)
60int(1)
61
62%unicode|string%(12) "%r\0%r*%r\0%rpro_value"
63int(10)
64int(1)
65
66bool(true)
67Done
68