mirror of
https://github.com/php/php-src.git
synced 2024-11-28 04:14:26 +08:00
29 lines
398 B
PHP
Executable File
29 lines
398 B
PHP
Executable File
--TEST--
|
|
Closure 036: Rebinding closure $this on property access, using scope
|
|
--FILE--
|
|
<?php
|
|
|
|
$instance = 0;
|
|
|
|
class Test {
|
|
private $value = 42;
|
|
function __construct() {
|
|
global $instance;
|
|
$this->instance = ++$instance;
|
|
}
|
|
}
|
|
|
|
$o = new Test;
|
|
$o->func = function () {
|
|
var_dump($this->value);
|
|
};
|
|
$func = $o->func;
|
|
$func();
|
|
|
|
var_dump($instance);
|
|
?>
|
|
===DONE===
|
|
--EXPECTF--
|
|
int(42)
|
|
int(1)
|
|
===DONE===
|