1--TEST--
2Invalid union type variance: Using parent of class in return type
3--FILE--
4<?php
5
6class X {}
7class Y extends X {}
8
9class A {
10    public function method(): Y|string {}
11}
12class B extends A {
13    public function method(): X|string {}
14}
15
16?>
17--EXPECTF--
18Fatal error: Declaration of B::method(): X|string must be compatible with A::method(): Y|string in %s on line %d
19