1--TEST--
2ReflectionClass::getInterfaces() - odd ampersand behaviour.
3--CREDITS--
4Robin Fernandes <robinf@php.net>
5Steve Seear <stevseea@php.net>
6--FILE--
7<?php
8
9echo "An object is in an array and is referenced. As expected, var_dumping the array shows '&':\n";
10$a = array(new stdclass);
11$b =& $a[0];
12var_dump($a);
13
14echo "Naturally, this remains true if we modify the object:\n";
15$a[0]->x = 1;
16var_dump($a);
17
18
19echo "\n\nObtain the array of interfaces implemented by C.\n";
20interface I {}
21class C implements I {}
22$rc = new ReflectionClass('C');
23$a = $rc->getInterfaces();
24echo "The result is an array in which each element is an object (an instance of ReflectionClass)\n";
25echo "Var_dumping this array shows that the elements are referenced. By what?\n";
26var_dump($a);
27
28echo "Modify the object, and it is apparently no longer referenced.\n";
29$a['I']->x = 1;
30var_dump($a);
31
32?>
33--EXPECTF--
34An object is in an array and is referenced. As expected, var_dumping the array shows '&':
35array(1) {
36  [0]=>
37  &object(stdClass)#%d (0) {
38  }
39}
40Naturally, this remains true if we modify the object:
41array(1) {
42  [0]=>
43  &object(stdClass)#%d (1) {
44    ["x"]=>
45    int(1)
46  }
47}
48
49
50Obtain the array of interfaces implemented by C.
51The result is an array in which each element is an object (an instance of ReflectionClass)
52Var_dumping this array shows that the elements are referenced. By what?
53array(1) {
54  ["I"]=>
55  &object(ReflectionClass)#%d (1) {
56    ["name"]=>
57    string(1) "I"
58  }
59}
60Modify the object, and it is apparently no longer referenced.
61array(1) {
62  ["I"]=>
63  object(ReflectionClass)#%d (2) {
64    ["name"]=>
65    string(1) "I"
66    ["x"]=>
67    int(1)
68  }
69}