call_user_func_002.phpt 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Testing call_user_func() with autoload and passing invalid params
  3. --FILE--
  4. <?php
  5. spl_autoload_register(function ($class) {
  6. var_dump($class);
  7. });
  8. try {
  9. call_user_func(array('foo', 'bar'));
  10. } catch (TypeError $e) {
  11. echo $e->getMessage(), "\n";
  12. }
  13. try {
  14. call_user_func(array('', 'bar'));
  15. } catch (TypeError $e) {
  16. echo $e->getMessage(), "\n";
  17. }
  18. try {
  19. call_user_func(array($foo, 'bar'));
  20. } catch (TypeError $e) {
  21. echo $e->getMessage(), "\n";
  22. }
  23. try {
  24. call_user_func(array($foo, ''));
  25. } catch (TypeError $e) {
  26. echo $e->getMessage(), "\n";
  27. }
  28. ?>
  29. --EXPECTF--
  30. string(3) "foo"
  31. call_user_func(): Argument #1 ($callback) must be a valid callback, class "foo" not found
  32. call_user_func(): Argument #1 ($callback) must be a valid callback, class "" not found
  33. Warning: Undefined variable $foo in %s on line %d
  34. call_user_func(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object
  35. Warning: Undefined variable $foo in %s on line %d
  36. call_user_func(): Argument #1 ($callback) must be a valid callback, first array member is not a valid class name or object