bug75573.phpt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. --TEST--
  2. Bug #75573 (Segmentation fault in 7.1.12 and 7.0.26)
  3. --FILE--
  4. <?php
  5. class A
  6. {
  7. var $_stdObject;
  8. function initialize($properties = FALSE) {
  9. $this->_stdObject = $properties ? (object) $properties : new stdClass();
  10. parent::initialize();
  11. }
  12. function &__get($property)
  13. {
  14. if (isset($this->_stdObject->{$property})) {
  15. $retval =& $this->_stdObject->{$property};
  16. return $retval;
  17. } else {
  18. return NULL;
  19. }
  20. }
  21. function &__set($property, $value)
  22. {
  23. return $this->_stdObject->{$property} = $value;
  24. }
  25. function __isset($property_name)
  26. {
  27. return isset($this->_stdObject->{$property_name});
  28. }
  29. }
  30. class B extends A
  31. {
  32. function initialize($properties = array())
  33. {
  34. parent::initialize($properties);
  35. }
  36. function &__get($property)
  37. {
  38. if (isset($this->settings) && isset($this->settings[$property])) {
  39. $retval =& $this->settings[$property];
  40. return $retval;
  41. } else {
  42. return parent::__get($property);
  43. }
  44. }
  45. }
  46. $b = new B();
  47. $b->settings = [ "foo" => "bar", "name" => "abc" ];
  48. var_dump($b->name);
  49. var_dump($b->settings);
  50. ?>
  51. --EXPECTF--
  52. Warning: Creating default object from empty value in %sbug75573.php on line %d
  53. Notice: Only variable references should be returned by reference in %sbug75573.php on line %d
  54. string(3) "abc"
  55. array(2) {
  56. ["foo"]=>
  57. string(3) "bar"
  58. ["name"]=>
  59. string(3) "abc"
  60. }