bug27798.phpt 956 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. --EXPECT--
  30. Base::__construct
  31. array(3) {
  32. ["Foo"]=>
  33. int(1)
  34. ["Bar"]=>
  35. int(2)
  36. ["Baz"]=>
  37. int(3)
  38. }
  39. array(1) {
  40. ["Foo"]=>
  41. int(1)
  42. }
  43. Base::__construct
  44. array(3) {
  45. ["Foo"]=>
  46. int(1)
  47. ["Bar"]=>
  48. int(2)
  49. ["Baz"]=>
  50. int(3)
  51. }
  52. Child::__construct
  53. array(3) {
  54. ["Foo"]=>
  55. int(1)
  56. ["Bar"]=>
  57. int(2)
  58. ["Baz"]=>
  59. int(4)
  60. }
  61. array(1) {
  62. ["Foo"]=>
  63. int(1)
  64. }