array_map_object2.phpt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. * Testing array_map() for following object functionalities:
  11. * 1) non-existent class
  12. * 2) existent class and non-existent function
  13. */
  14. echo "*** Testing array_map() : with non-existent class and method ***\n";
  15. class SimpleClass
  16. {
  17. public $var1 = 1;
  18. public function square($n) {
  19. return $n * $n;
  20. }
  21. public static function cube($n) {
  22. return $n * $n * $n;
  23. }
  24. }
  25. echo "-- with non-existent class --\n";
  26. var_dump( array_map(array('non-existent', 'square'), array(1, 2)) );
  27. echo "-- with existent class and non-existent method --\n";
  28. var_dump( array_map(array('SimpleClass', 'non-existent'), array(1, 2)) );
  29. echo "Done";
  30. ?>
  31. --EXPECTF--
  32. *** Testing array_map() : with non-existent class and method ***
  33. -- with non-existent class --
  34. Warning: array_map() expects parameter 1 to be a valid callback, class 'non-existent' not found in %s on line %d
  35. NULL
  36. -- with existent class and non-existent method --
  37. 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
  38. NULL
  39. Done