bug72813.phpt 683 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Bug #72813 (Segfault with __get returned by ref)
  3. --FILE--
  4. <?php
  5. class Test
  6. {
  7. private $props = ['a' => 'text', 'b' => 1];
  8. public function &__get($prop)
  9. {
  10. return $this->props[$prop];
  11. }
  12. public function __set($prop, $value)
  13. {
  14. if ($prop === 'b') $value = [$value];
  15. $this->props[$prop] = $value;
  16. }
  17. public function getProperties()
  18. {
  19. return [$this->props];
  20. }
  21. }
  22. $obj = new Test;
  23. $obj->b = $obj->b;
  24. print_r($obj->getProperties());
  25. ?>
  26. --EXPECT--
  27. Array
  28. (
  29. [0] => Array
  30. (
  31. [a] => text
  32. [b] => Array
  33. (
  34. [0] => 1
  35. )
  36. )
  37. )