1--TEST--
2Typed property must be compatible when returned via &__get()
3--FILE--
4<?php
5
6class Test {
7	public $prop = "x";
8	public int $val;
9
10	public function &__get($name) {
11		return $this->prop;
12	}
13}
14
15$test = new Test;
16$dummyRef = &$test->prop;
17unset($test->val);
18var_dump($test);
19try {
20	var_dump($test->val);
21} catch (TypeError $e) { print $e->getMessage()."\n"; }
22var_dump($test);
23
24$test->prop = "y";
25var_dump($test->prop);
26
27?>
28--EXPECT--
29object(Test)#1 (1) {
30  ["prop"]=>
31  &string(1) "x"
32  ["val"]=>
33  uninitialized(int)
34}
35Typed property Test::$val must be int, string used
36object(Test)#1 (1) {
37  ["prop"]=>
38  &string(1) "x"
39  ["val"]=>
40  uninitialized(int)
41}
42string(1) "y"
43