Return to array_map_object2.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test array_map() function : object functionality - with non-existent class and method 3: --FILE-- 4: <?php 5: /* Prototype : array array_map ( callback $callback , array $arr1 [, array $... ] ) 6: * Description: Applies the callback to the elements of the given arrays 7: * Source code: ext/standard/array.c 8: */ 9: 10: /* 11: * Testing array_map() for following object functionalities: 12: * 1) non-existent class 13: * 2) existent class and non-existent function 14: */ 15: echo "*** Testing array_map() : with non-existent class and method ***\n"; 16: 17: class SimpleClass 18: { 19: public $var1 = 1; 20: public function square($n) { 21: return $n * $n; 22: } 23: public static function cube($n) { 24: return $n * $n * $n; 25: } 26: } 27: 28: echo "-- with non-existent class --\n"; 29: var_dump( array_map(array('non-existent', 'square'), array(1, 2)) ); 30: 31: echo "-- with existent class and non-existent method --\n"; 32: var_dump( array_map(array('SimpleClass', 'non-existent'), array(1, 2)) ); 33: 34: echo "Done"; 35: ?> 36: --EXPECTF-- 37: *** Testing array_map() : with non-existent class and method *** 38: -- with non-existent class -- 39: 40: Warning: array_map() expects parameter 1 to be a valid callback, class 'non-existent' not found in %s on line %d 41: NULL 42: -- with existent class and non-existent method -- 43: 44: Warning: array_map() expects parameter 1 to be a valid callback, class 'SimpleClass' does not have a method 'non-existent' in %s on line %d 45: NULL 46: Done