bug40431.phpt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. --TEST--
  2. Bug #40431 (dynamic properties may cause crash in ReflectionProperty methods)
  3. --FILE--
  4. <?php
  5. echo "=== 1st test ===\n";
  6. $Obj = new stdClass;
  7. $Obj->value = 'value';
  8. $RefObj = new ReflectionObject($Obj);
  9. $props = $RefObj->getProperties();
  10. var_dump($props);
  11. var_dump($props[0]->isStatic());
  12. var_dump($props[0]->isPrivate());
  13. var_dump($props[0]->isPublic());
  14. var_dump($props[0]->isProtected());
  15. echo "=== 2nd test ===\n";
  16. class test1 {
  17. }
  18. class test2 extends test1{
  19. }
  20. $Obj = new test2;
  21. $Obj->value = 'value';
  22. $RefObj = new ReflectionObject($Obj);
  23. $props = $RefObj->getProperties();
  24. var_dump($props);
  25. var_dump($props[0]->isStatic());
  26. var_dump($props[0]->isPrivate());
  27. var_dump($props[0]->isPublic());
  28. var_dump($props[0]->isProtected());
  29. echo "=== 3rd test ===\n";
  30. class test3 {
  31. }
  32. $Obj = new test3;
  33. $Obj->value = 'value';
  34. $RefObj = new ReflectionObject($Obj);
  35. $props = $RefObj->getProperties();
  36. var_dump($props);
  37. var_dump($props[0]->isStatic());
  38. var_dump($props[0]->isPrivate());
  39. var_dump($props[0]->isPublic());
  40. var_dump($props[0]->isProtected());
  41. echo "=== 4th test ===\n";
  42. class test5 {
  43. private $value = 1;
  44. }
  45. class test4 extends test5{
  46. }
  47. $Obj = new test4;
  48. $Obj->value = 'value';
  49. $RefObj = new ReflectionObject($Obj);
  50. $props = $RefObj->getProperties();
  51. var_dump($props);
  52. var_dump($props[0]->isStatic());
  53. var_dump($props[0]->isPrivate());
  54. var_dump($props[0]->isPublic());
  55. var_dump($props[0]->isProtected());
  56. echo "Done\n";
  57. ?>
  58. --EXPECTF--
  59. === 1st test ===
  60. array(1) {
  61. [0]=>
  62. object(ReflectionProperty)#%d (2) {
  63. ["name"]=>
  64. string(5) "value"
  65. ["class"]=>
  66. string(8) "stdClass"
  67. }
  68. }
  69. bool(false)
  70. bool(false)
  71. bool(true)
  72. bool(false)
  73. === 2nd test ===
  74. array(1) {
  75. [0]=>
  76. object(ReflectionProperty)#%d (2) {
  77. ["name"]=>
  78. string(5) "value"
  79. ["class"]=>
  80. string(5) "test2"
  81. }
  82. }
  83. bool(false)
  84. bool(false)
  85. bool(true)
  86. bool(false)
  87. === 3rd test ===
  88. array(1) {
  89. [0]=>
  90. object(ReflectionProperty)#%d (2) {
  91. ["name"]=>
  92. string(5) "value"
  93. ["class"]=>
  94. string(5) "test3"
  95. }
  96. }
  97. bool(false)
  98. bool(false)
  99. bool(true)
  100. bool(false)
  101. === 4th test ===
  102. array(1) {
  103. [0]=>
  104. object(ReflectionProperty)#%d (2) {
  105. ["name"]=>
  106. string(5) "value"
  107. ["class"]=>
  108. string(5) "test4"
  109. }
  110. }
  111. bool(false)
  112. bool(false)
  113. bool(true)
  114. bool(false)
  115. Done