objects_024.phpt 727 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. --TEST--
  2. Testing direct assigning for property of object returned by function
  3. --FILE--
  4. <?php
  5. class foo {
  6. static $bar = array();
  7. public function __set($a, $b) {
  8. self::$bar[] = $b;
  9. }
  10. public function __get($a) {
  11. /* last */
  12. return self::$bar[count(self::$bar)-1];
  13. }
  14. }
  15. function test() {
  16. return new foo;
  17. }
  18. $a = test()->bar = 1;
  19. var_dump($a, count(foo::$bar), test()->whatever);
  20. print "\n";
  21. $a = test()->bar = NULL;
  22. var_dump($a, count(foo::$bar), test()->whatever);
  23. print "\n";
  24. $a = test()->bar = test();
  25. var_dump($a, count(foo::$bar), test()->whatever);
  26. print "\n";
  27. ?>
  28. --EXPECTF--
  29. int(1)
  30. int(1)
  31. int(1)
  32. NULL
  33. int(2)
  34. NULL
  35. object(foo)#%d (0) {
  36. }
  37. int(3)
  38. object(foo)#%d (0) {
  39. }