-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
GenericStaticType
in @phpstan-self-out
- Loading branch information
1 parent
b4f41c7
commit dab99cb
Showing
4 changed files
with
118 additions
and
29 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
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,61 @@ | ||
<?php | ||
|
||
namespace Bug12575; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
/** | ||
* @template T of object | ||
*/ | ||
class Foo | ||
{ | ||
|
||
/** | ||
* @template U of object | ||
* @param class-string<U> $class | ||
* @return $this | ||
* @phpstan-self-out static<T&U> | ||
*/ | ||
public function add(string $class) | ||
{ | ||
return $this; | ||
} | ||
|
||
} | ||
|
||
/** | ||
* @template T of object | ||
* @extends Foo<T> | ||
*/ | ||
class Bar extends Foo | ||
{ | ||
|
||
} | ||
|
||
interface A | ||
{ | ||
|
||
} | ||
|
||
interface B | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @param Bar<A> $bar | ||
* @return void | ||
*/ | ||
function doFoo(Bar $bar): void { | ||
assertType('Bug12575\\Bar<Bug12575\\A&Bug12575\\B>', $bar->add(B::class)); | ||
assertType('Bug12575\\Bar<Bug12575\\A&Bug12575\\B>', $bar); | ||
}; | ||
|
||
/** | ||
* @param Bar<A> $bar | ||
* @return void | ||
*/ | ||
function doBar(Bar $bar): void { | ||
$bar->add(B::class); | ||
assertType('Bug12575\\Bar<Bug12575\\A&Bug12575\\B>', $bar); | ||
}; |