bug29210.phpt 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. --TEST--
  2. Bug #29210 (Function is_callable does not support private and protected methods)
  3. --FILE--
  4. <?php
  5. class test_class {
  6. private function test_func1() {
  7. echo "test_func1\n";
  8. }
  9. protected function test_func2() {
  10. echo "test_func2\n";
  11. }
  12. static private function test_func3() {
  13. echo "test_func3\n";
  14. }
  15. static protected function test_func4() {
  16. echo "test_func4\n";
  17. }
  18. function test() {
  19. if (is_callable(array($this,'test_func1'))) {
  20. $this->test_func1();
  21. } else {
  22. echo "test_func1 isn't callable from inside\n";
  23. }
  24. if (is_callable(array($this,'test_func2'))) {
  25. $this->test_func2();
  26. } else {
  27. echo "test_func2 isn't callable from inside\n";
  28. }
  29. if (is_callable(array('test_class','test_func3'))) {
  30. test_class::test_func3();
  31. } else {
  32. echo "test_func3 isn't callable from inside\n";
  33. }
  34. if (is_callable(array('test_class','test_func4'))) {
  35. test_class::test_func4();
  36. } else {
  37. echo "test_func4 isn't callable from inside\n";
  38. }
  39. }
  40. }
  41. class foo extends test_class {
  42. function test() {
  43. if (is_callable(array($this,'test_func1'))) {
  44. $this->test_func1();
  45. } else {
  46. echo "test_func1 isn't callable from child\n";
  47. }
  48. if (is_callable(array($this,'test_func2'))) {
  49. $this->test_func2();
  50. } else {
  51. echo "test_func2 isn't callable from child\n";
  52. }
  53. if (is_callable(array('test_class','test_func3'))) {
  54. test_class::test_func3();
  55. } else {
  56. echo "test_func3 isn't callable from child\n";
  57. }
  58. if (is_callable(array('test_class','test_func4'))) {
  59. test_class::test_func4();
  60. } else {
  61. echo "test_func4 isn't callable from child\n";
  62. }
  63. }
  64. }
  65. $object = new test_class;
  66. $object->test();
  67. if (is_callable(array($object,'test_func1'))) {
  68. $object->test_func1();
  69. } else {
  70. echo "test_func1 isn't callable from outside\n";
  71. }
  72. if (is_callable(array($object,'test_func2'))) {
  73. $object->test_func2();
  74. } else {
  75. echo "test_func2 isn't callable from outside\n";
  76. }
  77. if (is_callable(array('test_class','test_func3'))) {
  78. test_class::test_func3();
  79. } else {
  80. echo "test_func3 isn't callable from outside\n";
  81. }
  82. if (is_callable(array('test_class','test_func4'))) {
  83. test_class::test_func4();
  84. } else {
  85. echo "test_func4 isn't callable from outside\n";
  86. }
  87. $object = new foo();
  88. $object->test();
  89. ?>
  90. --EXPECT--
  91. test_func1
  92. test_func2
  93. test_func3
  94. test_func4
  95. test_func1 isn't callable from outside
  96. test_func2 isn't callable from outside
  97. test_func3 isn't callable from outside
  98. test_func4 isn't callable from outside
  99. test_func1 isn't callable from child
  100. test_func2
  101. test_func3 isn't callable from child
  102. test_func4