Annotation of embedaddon/php/Zend/tests/closure_020.phpt, revision 1.1.1.2
1.1 misho 1: --TEST--
2: Closure 020: Trying to access private property outside class
3: --FILE--
4: <?php
5:
6: class foo {
7: private $test = 3;
8:
9: public function x() {
10: $a = &$this;
11: $this->a = function() use (&$a) { return $a; };
12: var_dump($this->a->__invoke());
13: var_dump(is_a($this->a, 'closure'));
14: var_dump(is_callable($this->a));
15:
16: return $this->a;
17: }
18: }
19:
20: $foo = new foo;
21: $y = $foo->x();
22: var_dump($y()->test);
23:
24: ?>
25: --EXPECTF--
1.1.1.2 ! misho 26: object(foo)#%d (2) {
1.1 misho 27: ["test":"foo":private]=>
28: int(3)
29: ["a"]=>
1.1.1.2 ! misho 30: object(Closure)#%d (2) {
1.1 misho 31: ["static"]=>
32: array(1) {
33: ["a"]=>
34: *RECURSION*
35: }
1.1.1.2 ! misho 36: ["this"]=>
! 37: *RECURSION*
1.1 misho 38: }
39: }
40: bool(true)
41: bool(true)
42:
43: Fatal error: Cannot access private property foo::$test in %s on line %d
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>