bug32660.phpt 824 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. Bug #32660 (Assignment by reference causes crash when field access is overloaded (__get))
  3. --FILE--
  4. <?php
  5. class A
  6. {
  7. public $q;
  8. function __construct()
  9. {
  10. $this->q = 3;//array();
  11. }
  12. function __get($name)
  13. {
  14. return $this->q;
  15. }
  16. }
  17. $a = new A;
  18. $b = "short";
  19. $c =& $a->whatever;
  20. $c = "long";
  21. print_r($a);
  22. $a->whatever =& $b;
  23. $b = "much longer";
  24. print_r($a);
  25. ?>
  26. --EXPECTF--
  27. Notice: Indirect modification of overloaded property A::$whatever has no effect in %sbug32660.php on line 20
  28. A Object
  29. (
  30. [q] => 3
  31. )
  32. Notice: Indirect modification of overloaded property A::$whatever has no effect in %sbug32660.php on line 23
  33. Fatal error: Uncaught Error: Cannot assign by reference to overloaded object in %sbug32660.php:23
  34. Stack trace:
  35. #0 {main}
  36. thrown in %sbug32660.php on line 23