mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
44 lines
621 B
PHP
Executable File
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===
|