1--TEST--
2Valid inheritence - co-variance
3--FILE--
4<?php
5
6interface A {}
7interface B {}
8interface C {}
9
10class Test implements A, B, C {}
11
12class Foo {
13    public function foo(): A {
14        return new Test();
15    }
16}
17
18class FooChild extends Foo {
19    public function foo(): A&B {
20        return new Test();
21    }
22}
23
24class FooSecondChild extends FooChild {
25    public function foo(): A&B&C {
26        return new Test();
27    }
28}
29
30$o = new FooChild();
31var_dump($o->foo());
32$o = new FooSecondChild();
33var_dump($o->foo());
34
35?>
36--EXPECTF--
37object(Test)#%d (0) {
38}
39object(Test)#%d (0) {
40}
41