Skip to content

Commit 092aee8

Browse files
committed
Regression test
1 parent c26886d commit 092aee8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: tests/PHPStan/Analyser/nsrt/bug-11188.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Bug11188;
4+
5+
use DateTime;
6+
use function PHPStan\Testing\assertType;
7+
8+
/**
9+
* @template TDefault of string
10+
* @template TExplicit of string
11+
*
12+
* @param TDefault $abstract
13+
* @param array<string, mixed> $parameters
14+
* @param TExplicit|null $type
15+
* @return (
16+
* $type is class-string ? new<TExplicit> :
17+
* $abstract is class-string ? new<TDefault> : mixed
18+
* )
19+
*/
20+
function instance(string $abstract, array $parameters = [], ?string $type = null): mixed
21+
{
22+
return 'something';
23+
}
24+
25+
function (): void {
26+
assertType(DateTime::class, instance('cache', [], DateTime::class));
27+
assertType(DateTime::class, instance(DateTime::class));
28+
};

0 commit comments

Comments
 (0)