1--TEST--
2Assigning an object of known type to a reference variable
3--FILE--
4<?php
5
6class Test {
7    public int $x = 42;
8}
9
10function test1() {
11    $r =& $o;
12    $o = new Test;
13    $r = new stdClass;
14    $r->x = 3.141;
15    var_dump(is_float($o->x));
16}
17
18function test2($o) {
19    $r =& $o;
20    if ($o instanceof Test) {
21        $r = new stdClass;
22        $r->x = 3.141;
23        var_dump(is_float($o->x));
24    }
25}
26
27function test3(Test &$o) {
28    $GLOBALS['r'] = new stdClass;
29    $GLOBALS['r']->x = 3.141;
30    var_dump(is_float($o->x));
31}
32
33test1();
34test2(new Test);
35$r = new Test;
36test3($r);
37
38?>
39--EXPECT--
40bool(true)
41bool(true)
42bool(true)
43