xref: /PHP-5.3/Zend/tests/closure_026.phpt (revision c6d89bd4)
1--TEST--
2Closure 026: Assigning a closure object to an array in $this
3--FILE--
4<?php
5
6class foo {
7	public function __construct() {
8		$a =& $this;
9
10		$a->a[] = function() {
11			return 1;
12		};
13
14		var_dump($this);
15
16		var_dump($this->a[0]());
17	}
18}
19
20$x = new foo;
21
22print "--------------\n";
23
24foreach ($x as $b => $c) {
25	var_dump($b, $c);
26	var_dump($c[0]());
27}
28
29?>
30--EXPECTF--
31object(foo)#%d (1) {
32  ["a"]=>
33  array(1) {
34    [0]=>
35    object(Closure)#%d (0) {
36    }
37  }
38}
39int(1)
40--------------
41string(1) "a"
42array(1) {
43  [0]=>
44  object(Closure)#%d (0) {
45  }
46}
47int(1)
48