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 (1) { 37 ["this"]=> 38 *RECURSION* 39 } 40 } 41} 42int(1) 43-------------- 44string(1) "a" 45array(1) { 46 [0]=> 47 object(Closure)#%d (1) { 48 ["this"]=> 49 object(foo)#%d (1) { 50 ["a"]=> 51 *RECURSION* 52 } 53 } 54} 55int(1) 56