1--TEST--
2Pass uninitialised objects and arrays by reference to test implicit initialisation.
3--FILE--
4<?php
5
6function refs(&$ref1, &$ref2) {
7  $ref1 = "Ref1 changed";
8  $ref2 = "Ref2 changed";
9}
10
11
12class C {
13
14    function __construct(&$ref1, &$ref2) {
15      $ref1 = "Ref1 changed";
16      $ref2 = "Ref2 changed";
17    }
18
19    function refs(&$ref1, &$ref2) {
20      $ref1 = "Ref1 changed";
21      $ref2 = "Ref2 changed";
22    }
23
24    static function static_refs(&$ref1, &$ref2) {
25      $ref1 = "Ref1 changed";
26      $ref2 = "Ref2 changed";
27    }
28
29}
30
31echo "\n ---- Pass uninitialised array & object by ref: function call ---\n";
32unset($u1, $u2);
33refs($u1[0], $u2[0][1]);
34var_dump($u1, $u2);
35
36echo "\n ---- Pass uninitialised arrays & objects by ref: static method call ---\n";
37unset($u1, $u2);
38C::static_refs($u1[0], $u2[0][1]);
39var_dump($u1, $u2);
40
41echo "\n\n---- Pass uninitialised arrays & objects by ref: constructor ---\n";
42unset($u1, $u2);
43$c = new C($u1[0], $u2[0][1]);
44var_dump($u1, $u2);
45
46echo "\n ---- Pass uninitialised arrays & objects by ref: instance method call ---\n";
47unset($u1, $u2);
48$c->refs($u1[0], $u2[0][1]);
49var_dump($u1, $u2);
50
51?>
52--EXPECT--
53---- Pass uninitialised array & object by ref: function call ---
54array(1) {
55  [0]=>
56  string(12) "Ref1 changed"
57}
58array(1) {
59  [0]=>
60  array(1) {
61    [1]=>
62    string(12) "Ref2 changed"
63  }
64}
65
66 ---- Pass uninitialised arrays & objects by ref: static method call ---
67array(1) {
68  [0]=>
69  string(12) "Ref1 changed"
70}
71array(1) {
72  [0]=>
73  array(1) {
74    [1]=>
75    string(12) "Ref2 changed"
76  }
77}
78
79
80---- Pass uninitialised arrays & objects by ref: constructor ---
81array(1) {
82  [0]=>
83  string(12) "Ref1 changed"
84}
85array(1) {
86  [0]=>
87  array(1) {
88    [1]=>
89    string(12) "Ref2 changed"
90  }
91}
92
93 ---- Pass uninitialised arrays & objects by ref: instance method call ---
94array(1) {
95  [0]=>
96  string(12) "Ref1 changed"
97}
98array(1) {
99  [0]=>
100  array(1) {
101    [1]=>
102    string(12) "Ref2 changed"
103  }
104}
105