1--TEST--
2Missing one element of intersection type
3--FILE--
4<?php
5
6interface X {}
7interface Y {}
8interface Z {}
9
10class A implements X {}
11
12class Collection {
13    public X&Y $intersect;
14}
15
16function foo(): X&Y {
17    return new A();
18}
19
20function bar(X&Y $o): void {
21    var_dump($o);
22}
23
24try {
25    $o = foo();
26    var_dump($o);
27} catch (\TypeError $e) {
28    echo $e->getMessage(), "\n";
29}
30
31$c = new Collection();
32$a = new A();
33
34try {
35    $c->intersect = $a;
36} catch (\TypeError $e) {
37    echo $e->getMessage(), "\n";
38}
39
40try {
41    bar($a);
42} catch (\TypeError $e) {
43    echo $e->getMessage(), "\n";
44}
45
46?>
47--EXPECTF--
48foo(): Return value must be of type X&Y, A returned
49Cannot assign A to property Collection::$intersect of type X&Y
50bar(): Argument #1 ($o) must be of type X&Y, A given, called in %s on line %d
51