xref: /PHP-5.5/Zend/tests/dereference_011.phpt (revision 99c31b31)
1--TEST--
2Testing array dereference with chaining
3--FILE--
4<?php
5
6error_reporting(E_ALL);
7
8class foo {
9	public $arr;
10
11	public function &a() {
12		return $this->arr;
13	}
14}
15
16$foo = new foo;
17
18$h = &$foo->a();
19$h[] = 1;
20$h[] = $foo;
21var_dump($foo->a()[1]->arr[1]->a()[1]->arr[1]->arr[0]);
22var_dump($foo->a()[1]);
23var_dump($foo->a()[1]->arr[1]);
24
25?>
26--EXPECTF--
27int(1)
28object(foo)#%d (1) {
29  ["arr"]=>
30  &array(2) {
31    [0]=>
32    int(1)
33    [1]=>
34    *RECURSION*
35  }
36}
37object(foo)#%d (1) {
38  ["arr"]=>
39  &array(2) {
40    [0]=>
41    int(1)
42    [1]=>
43    *RECURSION*
44  }
45}
46