bug32290.phpt 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. --TEST--
  2. Bug #32290 (calling call_user_func_array() ends in infinite loop within child class)
  3. --INI--
  4. error_reporting=8191
  5. --FILE--
  6. <?php
  7. class TestA
  8. {
  9. public function doSomething($i)
  10. {
  11. echo __METHOD__ . "($i)\n";
  12. return --$i;
  13. }
  14. public function doSomethingThis($i)
  15. {
  16. echo __METHOD__ . "($i)\n";
  17. return --$i;
  18. }
  19. public function doSomethingParent($i)
  20. {
  21. echo __METHOD__ . "($i)\n";
  22. return --$i;
  23. }
  24. public function doSomethingParentThis($i)
  25. {
  26. echo __METHOD__ . "($i)\n";
  27. return --$i;
  28. }
  29. public static function doSomethingStatic($i)
  30. {
  31. echo __METHOD__ . "($i)\n";
  32. return --$i;
  33. }
  34. }
  35. class TestB extends TestA
  36. {
  37. public function doSomething($i)
  38. {
  39. echo __METHOD__ . "($i)\n";
  40. $i++;
  41. if ($i >= 5) return 5;
  42. return call_user_func_array(array("TestA", "doSomething"), array($i));
  43. }
  44. public function doSomethingThis($i)
  45. {
  46. echo __METHOD__ . "($i)\n";
  47. $i++;
  48. if ($i >= 5) return 5;
  49. return call_user_func_array(array($this, "TestA::doSomethingThis"), array($i));
  50. }
  51. public function doSomethingParent($i)
  52. {
  53. echo __METHOD__ . "($i)\n";
  54. $i++;
  55. if ($i >= 5) return 5;
  56. return call_user_func_array(array("parent", "doSomethingParent"), array($i));
  57. }
  58. public function doSomethingParentThis($i)
  59. {
  60. echo __METHOD__ . "($i)\n";
  61. $i++;
  62. if ($i >= 5) return 5;
  63. return call_user_func_array(array($this, "parent::doSomethingParentThis"), array($i));
  64. }
  65. public static function doSomethingStatic($i)
  66. {
  67. echo __METHOD__ . "($i)\n";
  68. $i++;
  69. if ($i >= 5) return 5;
  70. return call_user_func_array(array("TestA", "doSomethingStatic"), array($i));
  71. }
  72. }
  73. $x = new TestB();
  74. echo "===A===\n";
  75. var_dump($x->doSomething(1));
  76. echo "\n===B===\n";
  77. var_dump($x->doSomethingThis(1));
  78. echo "\n===C===\n";
  79. var_dump($x->doSomethingParent(1));
  80. echo "\n===D===\n";
  81. var_dump($x->doSomethingParentThis(1));
  82. echo "\n===E===\n";
  83. var_dump($x->doSomethingStatic(1));
  84. ?>
  85. --EXPECT--
  86. ===A===
  87. TestB::doSomething(1)
  88. TestA::doSomething(2)
  89. int(1)
  90. ===B===
  91. TestB::doSomethingThis(1)
  92. TestA::doSomethingThis(2)
  93. int(1)
  94. ===C===
  95. TestB::doSomethingParent(1)
  96. TestA::doSomethingParent(2)
  97. int(1)
  98. ===D===
  99. TestB::doSomethingParentThis(1)
  100. TestA::doSomethingParentThis(2)
  101. int(1)
  102. ===E===
  103. TestB::doSomethingStatic(1)
  104. TestA::doSomethingStatic(2)
  105. int(1)