1--TEST--
2Intersection types and typed reference
3--FILE--
4<?php
5
6interface X {}
7interface Y {}
8interface Z {}
9
10class A implements X, Y, Z {}
11class B implements X, Y {}
12
13class Test {
14    public X&Y $y;
15    public X&Z $z;
16}
17$test = new Test;
18$r = new A;
19$test->y =& $r;
20$test->z =& $r;
21
22try {
23    $r = new B;
24} catch (\TypeError $e) {
25    echo $e->getMessage(), \PHP_EOL;
26}
27
28?>
29--EXPECT--
30Cannot assign B to reference held by property Test::$z of type X&Z
31