2 class C
implements ArrayAccess
{
4 public function offsetGet($k) {
5 echo "C::offsetGet $k\n";
8 public function offsetSet($k, $v) { $this->arr
[$k] = $v; }
9 public function offsetExists($k) { return isset($this->arr
[$k]); }
10 public function offsetUnset($k) { unset($this->arr
[$k]); }
12 class D
implements ArrayAccess
{
13 public static $a, $b, $c, $d;
14 public $arr = array();
15 public function __construct($x, $y) {
19 public function offsetGet($k) {
21 echo "D::offsetGet $k\n";
22 $a = self
::$a; $b = self
::$b; $c = self
::$c; $d = self
::$d;
23 echo " a=$a b=$b c=$c d=$d\n";
24 return $this->arr
[$k];
26 public function offsetSet($k, $v) { $this->arr
[$k] = $v; }
27 public function offsetExists($k) { return isset($this->arr
[$k]); }
28 public function offsetUnset($k) { unset($this->arr
[$k]); }
31 $x->arr
[0] = new D(11, 22);
32 $x->arr
[1] = new D(33, 44);
33 D
::$a = D
::$b = D
::$c = D
::$d = 0;
34 foreach (array($x) as list(list(D
::$a,D
::$b),list(D
::$c,D
::$d))) {}