1--TEST--
2Basic ReflectionReference functionality
3--FILE--
4<?php
5
6$ary = [0, 1, 2, 3];
7$ref1 =& $ary[1];
8unset($ref1);
9$ref2 =& $ary[2];
10$ref3 =& $ary[3];
11
12echo "fromArrayElement():\n";
13$r0 = ReflectionReference::fromArrayElement($ary, 0);
14var_dump($r0 === null);
15$r1 = ReflectionReference::fromArrayElement($ary, 1);
16var_dump($r1 === null);
17$r2 = ReflectionReference::fromArrayElement($ary, 2);
18var_dump($r2 instanceof ReflectionReference);
19$r3 = ReflectionReference::fromArrayElement($ary, 3);
20var_dump($r2 instanceof ReflectionReference);
21
22echo "getId() #1:\n";
23var_dump($r2->getId() === $r2->getId());
24var_dump($r3->getId() === $r3->getId());
25var_dump($r2->getId() !== $r3->getId());
26
27echo "getId() #2:\n";
28$ary2 = [&$ary[2], &$ref3];
29$r2_2 = ReflectionReference::fromArrayElement($ary2, 0);
30$r3_2 = ReflectionReference::fromArrayElement($ary2, 1);
31var_dump($r2->getId() === $r2_2->getId());
32var_dump($r3->getId() === $r3_2->getId());
33
34echo "getId() #3:\n";
35$r2_id = $r2->getId();
36$r3_id = $r3->getId();
37unset($r0, $r1, $r2, $r3, $r2_2, $r3_2);
38$r2 = ReflectionReference::fromArrayElement($ary, 2);
39$r3 = ReflectionReference::fromArrayElement($ary, 3);
40var_dump($r2_id === $r2->getId());
41var_dump($r3_id === $r3->getId());
42
43?>
44--EXPECT--
45fromArrayElement():
46bool(true)
47bool(true)
48bool(true)
49bool(true)
50getId() #1:
51bool(true)
52bool(true)
53bool(true)
54getId() #2:
55bool(true)
56bool(true)
57getId() #3:
58bool(true)
59bool(true)
60