bug36214.phpt 977 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. --TEST--
  2. Bug #36214 (__get method works properly only when conditional operator is used)
  3. --FILE--
  4. <?php
  5. class context {
  6. public $stack = array();
  7. public function __set($name,$var) {
  8. $this->stack[$name] = $var;return;
  9. }
  10. public function &__get($name) {
  11. return $this->stack[$name];
  12. }
  13. }
  14. $ctx = new context;
  15. $ctx->comment_preview = array();
  16. $ctx->comment_preview[0] = 1;
  17. $ctx->comment_preview[1] = 2;
  18. var_dump($ctx->comment_preview);
  19. $comment_preview = array();
  20. $comment_preview[0] = 1;
  21. $comment_preview[1] = 2;
  22. $ctx->comment_preview = $comment_preview;
  23. var_dump($ctx->comment_preview);
  24. $ctx->comment_preview = new ArrayObject();
  25. $ctx->comment_preview[0] = 1;
  26. $ctx->comment_preview[1] = 2;
  27. var_dump($ctx->comment_preview);
  28. ?>
  29. --EXPECTF--
  30. array(2) {
  31. [0]=>
  32. int(1)
  33. [1]=>
  34. int(2)
  35. }
  36. array(2) {
  37. [0]=>
  38. int(1)
  39. [1]=>
  40. int(2)
  41. }
  42. object(ArrayObject)#%d (1) {
  43. ["storage":"ArrayObject":private]=>
  44. array(2) {
  45. [0]=>
  46. int(1)
  47. [1]=>
  48. int(2)
  49. }
  50. }