forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-9961.php
More file actions
35 lines (28 loc) · 973 Bytes
/
bug-9961.php
File metadata and controls
35 lines (28 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php declare(strict_types = 1);
namespace Bug9961;
use function PHPStan\Testing\assertType;
interface Ia {}
interface Ib {}
interface Ic {}
interface Id {}
class A implements Ia, Ib {}
class HelloWorld
{
/**
* @template T of (Ia&Ib)|(Ic&Id)
* @param T $a
* @return T
*/
public function sayHello(Ia|Ic $a): mixed
{
if ($a instanceof Ic && $a instanceof Id) {
assertType('T of Bug9961\Ic&Bug9961\Id (method Bug9961\HelloWorld::sayHello(), argument)', $a);
} elseif ($a instanceof A) {
assertType('Bug9961\A&T of T of Bug9961\Ia&Bug9961\Ib (method Bug9961\HelloWorld::sayHello(), argument) (method Bug9961\HelloWorld::sayHello(), argument)', $a);
} else {
throw new \Exception;
}
assertType('(Bug9961\A&T of T of Bug9961\Ia&Bug9961\Ib (method Bug9961\HelloWorld::sayHello(), argument) (method Bug9961\HelloWorld::sayHello(), argument))|T of Bug9961\Ic&Bug9961\Id (method Bug9961\HelloWorld::sayHello(), argument)', $a);
return $a;
}
}