1--TEST-- 2Test array_map() function : object functionality - with non-existent class and method 3--FILE-- 4<?php 5/* 6 * Testing array_map() for following object functionalities: 7 * 1) non-existent class 8 * 2) existent class and non-existent function 9 */ 10echo "*** Testing array_map() : with non-existent class and method ***\n"; 11 12class SimpleClass 13{ 14 public $var1 = 1; 15 public function square($n) { 16 return $n * $n; 17 } 18 public static function cube($n) { 19 return $n * $n * $n; 20 } 21} 22 23echo "-- with non-existent class --\n"; 24try { 25 var_dump( array_map(array('non-existent', 'square'), array(1, 2)) ); 26} catch (TypeError $e) { 27 echo $e->getMessage(), "\n"; 28} 29 30echo "-- with existent class and non-existent method --\n"; 31try { 32 var_dump( array_map(array('SimpleClass', 'non-existent'), array(1, 2)) ); 33} catch (TypeError $e) { 34 echo $e->getMessage(), "\n"; 35} 36 37echo "Done"; 38?> 39--EXPECT-- 40*** Testing array_map() : with non-existent class and method *** 41-- with non-existent class -- 42array_map(): Argument #1 ($callback) must be a valid callback or null, class "non-existent" not found 43-- with existent class and non-existent method -- 44array_map(): Argument #1 ($callback) must be a valid callback or null, class SimpleClass does not have a method "non-existent" 45Done 46