bug48770_3.phpt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. Bug #48770 (call_user_func_array() fails to call parent from inheriting class)
  3. --FILE--
  4. <?php
  5. class A {
  6. public function func($str) {
  7. var_dump(__METHOD__ .': '. $str);
  8. }
  9. private function func2($str) {
  10. var_dump(__METHOD__ .': '. $str);
  11. }
  12. protected function func3($str) {
  13. var_dump(__METHOD__ .': '. $str);
  14. }
  15. }
  16. class B extends A {
  17. public function func($str) {
  18. call_user_func_array(array($this, 'self::func2'), array($str));
  19. call_user_func_array(array($this, 'self::func3'), array($str));
  20. try {
  21. call_user_func_array(array($this, 'self::inexistent'), array($str));
  22. } catch (\TypeError $e) {
  23. echo $e->getMessage() . \PHP_EOL;
  24. }
  25. }
  26. private function func2($str) {
  27. var_dump(__METHOD__ .': '. $str);
  28. }
  29. protected function func3($str) {
  30. var_dump(__METHOD__ .': '. $str);
  31. }
  32. }
  33. class C extends B {
  34. public function func($str) {
  35. parent::func($str);
  36. }
  37. }
  38. $c = new C;
  39. $c->func('This should work!');
  40. ?>
  41. --EXPECT--
  42. string(27) "B::func2: This should work!"
  43. string(27) "B::func3: This should work!"
  44. call_user_func_array(): Argument #1 ($callback) must be a valid callback, class C does not have a method "inexistent"