bug27798.phpt 918 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. --TEST--
  2. Bug #27798 (private / protected variables not exposed by get_object_vars() inside class)
  3. --FILE--
  4. <?php
  5. class Base
  6. {
  7. public $Foo = 1;
  8. protected $Bar = 2;
  9. private $Baz = 3;
  10. function __construct()
  11. {
  12. echo __METHOD__ . "\n";
  13. var_dump(get_object_vars($this));
  14. }
  15. }
  16. class Child extends Base
  17. {
  18. private $Baz = 4;
  19. function __construct()
  20. {
  21. parent::__construct();
  22. echo __METHOD__ . "\n";
  23. var_dump(get_object_vars($this));
  24. }
  25. }
  26. var_dump(get_object_vars(new Base));
  27. var_dump(get_object_vars(new Child));
  28. ?>
  29. ===DONE===
  30. --EXPECT--
  31. Base::__construct
  32. array(3) {
  33. ["Foo"]=>
  34. int(1)
  35. ["Bar"]=>
  36. int(2)
  37. ["Baz"]=>
  38. int(3)
  39. }
  40. array(1) {
  41. ["Foo"]=>
  42. int(1)
  43. }
  44. Base::__construct
  45. array(3) {
  46. ["Foo"]=>
  47. int(1)
  48. ["Bar"]=>
  49. int(2)
  50. ["Baz"]=>
  51. int(3)
  52. }
  53. Child::__construct
  54. array(3) {
  55. ["Baz"]=>
  56. int(4)
  57. ["Foo"]=>
  58. int(1)
  59. ["Bar"]=>
  60. int(2)
  61. }
  62. array(1) {
  63. ["Foo"]=>
  64. int(1)
  65. }
  66. ===DONE===