assign_ref_to_overloaded_prop.phpt 417 B

1234567891011121314151617181920212223
  1. --TEST--
  2. Cannot assign by reference to overloaded object, even if __get() returns by-ref
  3. --FILE--
  4. <?php
  5. class Test {
  6. private $x;
  7. public function &__get($name) {
  8. return $this->x;
  9. }
  10. }
  11. $test = new Test;
  12. $y = 5;
  13. $test->x =& $y;
  14. var_dump($test->x);
  15. ?>
  16. --EXPECTF--
  17. Fatal error: Uncaught Error: Cannot assign by reference to overloaded object in %s:%d
  18. Stack trace:
  19. #0 {main}
  20. thrown in %s on line %d