php-src/Zend/tests/closure_035.phpt
2009-01-03 18:21:51 +00:00

44 lines
621 B
PHP
Executable File

--TEST--
Closure 035: Rebinding closure $this on property access
--FILE--
<?php
$instance = 0;
class Test {
function __construct() {
global $instance;
$this->instance = ++$instance;
}
}
$o = new Test;
$o->func = function () {
var_dump($this);
};
$func = $o->func;
$func();
var_dump($instance);
?>
===DONE===
--EXPECTF--
object(Test)#%d (2) {
[u"instance"]=>
int(1)
[u"func"]=>
object(Closure)#%d (1) {
["this"]=>
object(Test)#%d (2) {
[u"instance"]=>
int(1)
[u"func"]=>
object(Closure)#2 (1) {
["this"]=>
*RECURSION*
}
}
}
}
int(1)
===DONE===