call_user_func_001.phpt 839 B

1234567891011121314151617181920212223242526272829303132333435
  1. --TEST--
  2. Testing call_user_func inside namespace
  3. --FILE--
  4. <?php
  5. namespace testing {
  6. function foobar($str) {
  7. var_dump($str);
  8. }
  9. abstract class bar {
  10. protected function prot($str) {
  11. print "Shouldn't be called!\n";
  12. }
  13. }
  14. class foo extends bar {
  15. private function priv($str) {
  16. print "Shouldn't be called!\n";
  17. }
  18. }
  19. call_user_func(__NAMESPACE__ .'\foobar', 'foobar');
  20. $class = __NAMESPACE__ .'\foo';
  21. call_user_func(array(new $class, 'priv'), 'foobar');
  22. call_user_func(array(new $class, 'prot'), 'foobar');
  23. }
  24. ?>
  25. --EXPECTF--
  26. string(6) "foobar"
  27. Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access private method testing\foo::priv() in %s on line %d
  28. Warning: call_user_func() expects parameter 1 to be a valid callback, cannot access protected method testing\foo::prot() in %s on line %d