Annotation of embedaddon/php/ext/standard/tests/array/array_walk_recursive_object1.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: Test array_walk_recursive() function : object functionality
                      3: --FILE--
                      4: <?php
                      5: /* Prototype  : bool array_walk_recursive(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: /* Passing object in place of an 'input' argument to test object functionality 
                     11:  */
                     12: echo "*** Testing array_walk_recursive() : object functionality ***\n";
                     13: 
                     14: /*
                     15:  * Prototype : callback(mixed $value, mixed $key, int $addvalue
                     16:  * Parameters : $value - values in given input array
                     17:  *              $key - keys in given input array
                     18:  *              $addvalue - value to be added
                     19:  * Description : Function adds the addvalue to each element of an array
                     20: */
                     21: 
                     22: function callback($value, $key, $user_data)
                     23: {
                     24:   var_dump($key);
                     25:   var_dump($value);
                     26:   var_dump($user_data);
                     27:   echo "\n";
                     28: }
                     29: 
                     30: class MyClass
                     31: {
                     32:   private $pri_value;
                     33:   public $pub_value;
                     34:   protected $pro_value;
                     35:   public function __construct($setVal)
                     36:   {
                     37:     $this->pri_value = $setVal;
                     38:     $this->pub_value = $setVal;
                     39:     $this->pro_value = $setVal;
                     40:   }
                     41: };    
                     42: 
                     43: // object for 'input' argument
                     44: $input = new MyClass(10); 
                     45: 
                     46: var_dump( array_walk_recursive($input, "callback", 1));
                     47: 
                     48: echo "Done"
                     49: ?>
                     50: --EXPECTF--
                     51: *** Testing array_walk_recursive() : object functionality ***
                     52: %unicode|string%(18) "%r\0%rMyClass%r\0%rpri_value"
                     53: int(10)
                     54: int(1)
                     55: 
                     56: %unicode|string%(9) "pub_value"
                     57: int(10)
                     58: int(1)
                     59: 
                     60: %unicode|string%(12) "%r\0%r*%r\0%rpro_value"
                     61: int(10)
                     62: int(1)
                     63: 
                     64: bool(true)
                     65: Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>