-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TemplateUnionType as part of intersection
- Loading branch information
1 parent
a3f587f
commit 4a45db5
Showing
3 changed files
with
85 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace Bug5000; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
class A { | ||
|
||
} | ||
|
||
class B { | ||
|
||
} | ||
|
||
/** | ||
* @template T of A|B | ||
*/ | ||
interface F | ||
{ | ||
|
||
/** | ||
* @return T[] | ||
*/ | ||
function getValues(): array; | ||
|
||
/** | ||
* @phpstan-param T $v | ||
* @return T | ||
*/ | ||
function getDetail(object $v); | ||
} | ||
|
||
class Foo | ||
{ | ||
|
||
/** | ||
* @template T of A|B | ||
* @phpstan-param F<T> $f | ||
*/ | ||
function foo(F $f): void { | ||
$values = $f->getValues(); | ||
assertType('array<T of Bug5000\A|Bug5000\B (method Bug5000\Foo::foo(), argument)>', $values); | ||
|
||
$f->getDetail($values[0]); | ||
assertType('array<T of Bug5000\A|Bug5000\B (method Bug5000\Foo::foo(), argument)>', $values); | ||
foreach($values as $val) { | ||
assertType('T of Bug5000\A|Bug5000\B (method Bug5000\Foo::foo(), argument)', $val); | ||
$f->getDetail($val); | ||
} | ||
} | ||
|
||
|
||
} |