bug75573.phpt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 __construct()
  9. {
  10. $this->_stdObject = new stdClass;
  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 &__get($property)
  33. {
  34. if (isset($this->settings) && isset($this->settings[$property])) {
  35. $retval =& $this->settings[$property];
  36. return $retval;
  37. } else {
  38. return parent::__get($property);
  39. }
  40. }
  41. }
  42. $b = new B();
  43. $b->settings = [ "foo" => "bar", "name" => "abc" ];
  44. var_dump($b->name);
  45. var_dump($b->settings);
  46. ?>
  47. --EXPECTF--
  48. Notice: Only variable references should be returned by reference in %s on line %d
  49. string(3) "abc"
  50. array(2) {
  51. ["foo"]=>
  52. string(3) "bar"
  53. ["name"]=>
  54. string(3) "abc"
  55. }