--TEST-- Test array_map() function : object functionality - class methods as callback function --FILE-- parent_obj = new ParentClass(); } public $var2 = 5; public static function staticChild($n) { return $n; } public function nonstaticChild($n) { return $n; } } $childobj = new ChildClass(); $parentobj = new ParentClass(); echo "-- accessing parent method from child class --\n"; var_dump( array_map(array('ChildClass', 'staticParent1'), $arr1) ); echo "-- accessing child method from parent class --\n"; try { var_dump( array_map(array('ParentClass', 'staticChild'), $arr1) ); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } echo "-- accessing parent method using child class object --\n"; var_dump( array_map(array($childobj, 'staticParent1'), $arr1) ); echo "-- accessing child method using parent class object --\n"; try { var_dump( array_map(array($parentobj, 'staticChild'), $arr1) ); } catch (TypeError $e) { echo $e->getMessage(), "\n"; } echo "Done"; ?> --EXPECT-- *** Testing array_map() : class methods as callback function *** -- accessing parent method from child class -- array(3) { [0]=> int(1) [1]=> int(5) [2]=> int(7) } -- accessing child method from parent class -- array_map(): Argument #1 ($callback) must be a valid callback, class ParentClass does not have a method "staticChild" -- accessing parent method using child class object -- array(3) { [0]=> int(1) [1]=> int(5) [2]=> int(7) } -- accessing child method using parent class object -- array_map(): Argument #1 ($callback) must be a valid callback, class ParentClass does not have a method "staticChild" Done