php-src/Zend/tests/closure_026.phpt

58 lines
714 B
Plaintext
Raw Normal View History

2008-07-28 22:10:00 +08:00
--TEST--
Closure 026: Assigning a closure object to an array in $this
--FILE--
<?php
class foo {
public function __construct() {
$a =& $this;
2018-10-14 23:23:43 +08:00
2008-07-28 22:10:00 +08:00
$a->a[] = function() {
2018-10-14 23:23:43 +08:00
return 1;
2008-07-28 22:10:00 +08:00
};
2018-10-14 23:23:43 +08:00
2008-07-28 22:10:00 +08:00
var_dump($this);
2018-10-14 23:23:43 +08:00
2008-07-28 22:10:00 +08:00
var_dump($this->a[0]());
}
}
$x = new foo;
print "--------------\n";
foreach ($x as $b => $c) {
var_dump($b, $c);
var_dump($c[0]());
}
?>
--EXPECTF--
object(foo)#%d (1) {
["a"]=>
array(1) {
[0]=>
object(Closure)#%d (1) {
["this"]=>
*RECURSION*
2008-07-28 22:10:00 +08:00
}
}
}
int(1)
--------------
string(1) "a"
array(1) {
[0]=>
2014-08-23 08:09:08 +08:00
object(Closure)#%d (1) {
["this"]=>
2014-08-23 08:09:08 +08:00
object(foo)#%d (1) {
["a"]=>
array(1) {
[0]=>
*RECURSION*
}
}
2008-07-28 22:10:00 +08:00
}
}
int(1)