php-src/Zend/tests/objects_024.phpt

53 lines
727 B
Plaintext
Raw Normal View History

2008-05-11 22:44:56 +00:00
--TEST--
Testing direct assigning for property of object returned by function
--FILE--
2018-09-16 17:16:42 +00:00
<?php
2008-05-11 22:44:56 +00:00
class foo {
2020-02-03 21:52:20 +00:00
static $bar = array();
2018-09-16 17:16:42 +00:00
2020-02-03 21:52:20 +00:00
public function __set($a, $b) {
self::$bar[] = $b;
}
2018-09-16 17:16:42 +00:00
2020-02-03 21:52:20 +00:00
public function __get($a) {
/* last */
return self::$bar[count(self::$bar)-1];
}
2008-05-11 22:44:56 +00:00
}
function test() {
2020-02-03 21:52:20 +00:00
return new foo;
2008-05-11 22:44:56 +00:00
}
$a = test()->bar = 1;
var_dump($a, count(foo::$bar), test()->whatever);
print "\n";
$a = test()->bar = NULL;
var_dump($a, count(foo::$bar), test()->whatever);
print "\n";
$a = test()->bar = test();
var_dump($a, count(foo::$bar), test()->whatever);
print "\n";
?>
--EXPECTF--
int(1)
int(1)
int(1)
NULL
int(2)
NULL
object(foo)#%d (0) {
}
int(3)
object(foo)#%d (0) {
}