1--TEST--
2Closure 026: Assigning a closure object to an array in $this
3--FILE--
4<?php
5
6class foo {
7    public $a;
8    public function __construct() {
9        $a =& $this;
10
11        $a->a[] = function() {
12            return 1;
13        };
14
15        var_dump($this);
16
17        var_dump($this->a[0]());
18    }
19}
20
21$x = new foo;
22
23print "--------------\n";
24
25foreach ($x as $b => $c) {
26    var_dump($b, $c);
27    var_dump($c[0]());
28}
29
30?>
31--EXPECTF--
32object(foo)#%d (1) {
33  ["a"]=>
34  array(1) {
35    [0]=>
36    object(Closure)#%d (4) {
37      ["name"]=>
38      string(%d) "{closure:%s:%d}"
39      ["file"]=>
40      string(%d) "%s"
41      ["line"]=>
42      int(%d)
43      ["this"]=>
44      *RECURSION*
45    }
46  }
47}
48int(1)
49--------------
50string(1) "a"
51array(1) {
52  [0]=>
53  object(Closure)#%d (4) {
54    ["name"]=>
55    string(%d) "{closure:%s:%d}"
56    ["file"]=>
57    string(%d) "%s"
58    ["line"]=>
59    int(%d)
60    ["this"]=>
61    object(foo)#%d (1) {
62      ["a"]=>
63      *RECURSION*
64    }
65  }
66}
67int(1)
68