1--TEST--
2Union with anonymous class type
3--FILE--
4<?php
5
6$a = new class {
7    public function testParam(self|string $a)
8    {
9    }
10    public function test(): self|string
11    {
12        return new \stdClass;
13    }
14};
15
16try {
17    $a->testParam(null);
18} catch (\Throwable $e) {
19    echo $e->getMessage()."\n";
20}
21
22try {
23    $a->test();
24} catch (\Throwable $e) {
25    echo $e->getMessage()."\n";
26}
27?>
28--EXPECTF--
29class@anonymous(): Argument #1 ($a) must be of type class@anonymous|string, null given, called in %s on line %d
30class@anonymous::test(): Return value must be of type class@anonymous|string, stdClass returned
31