xref: /PHP-5.5/Zend/tests/objects_024.phpt (revision f6c57d1f)
1--TEST--
2Testing direct assigning for property of object returned by function
3--FILE--
4<?php
5
6class foo {
7	static $bar = array();
8
9	public function __set($a, $b) {
10		self::$bar[] = $b;
11	}
12
13	public function __get($a) {
14		/* last */
15		return self::$bar[count(self::$bar)-1];
16	}
17}
18
19function test() {
20	return new foo;
21}
22
23$a = test()->bar = 1;
24var_dump($a, count(foo::$bar), test()->whatever);
25
26print "\n";
27
28$a = test()->bar = NULL;
29var_dump($a, count(foo::$bar), test()->whatever);
30
31print "\n";
32
33$a = test()->bar = test();
34var_dump($a, count(foo::$bar), test()->whatever);
35
36print "\n";
37
38?>
39--EXPECTF--
40int(1)
41int(1)
42int(1)
43
44NULL
45int(2)
46NULL
47
48object(foo)#%d (0) {
49}
50int(3)
51object(foo)#%d (0) {
52}
53
54