1--TEST--
2Closure 020: Trying to access private property outside class
3--FILE--
4<?php
5
6class foo {
7    private $test = 3;
8    public $a;
9
10    public function x() {
11        $a = &$this;
12        $this->a = function() use (&$a) { return $a; };
13        var_dump($this->a->__invoke());
14        var_dump(is_a($this->a, 'closure'));
15        var_dump(is_callable($this->a));
16
17        return $this->a;
18    }
19}
20
21$foo = new foo;
22$y = $foo->x();
23var_dump($y()->test);
24
25?>
26--EXPECTF--
27object(foo)#%d (2) {
28  ["test":"foo":private]=>
29  int(3)
30  ["a"]=>
31  object(Closure)#%d (5) {
32    ["name"]=>
33    string(%d) "{closure:%s:%d}"
34    ["file"]=>
35    string(%d) "%s"
36    ["line"]=>
37    int(%d)
38    ["static"]=>
39    array(1) {
40      ["a"]=>
41      *RECURSION*
42    }
43    ["this"]=>
44    *RECURSION*
45  }
46}
47bool(true)
48bool(true)
49
50Fatal error: Uncaught Error: Cannot access private property foo::$test in %s:%d
51Stack trace:
52#0 {main}
53  thrown in %s on line %d
54