-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nested generic type - correctly infer template types
- Loading branch information
1 parent
e4331af
commit 48aea56
Showing
5 changed files
with
48 additions
and
5 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,28 @@ | ||
<?php | ||
|
||
namespace Bug4642; | ||
|
||
use function PHPStan\Analyser\assertType; | ||
|
||
interface IEntity {} | ||
/** @template E of IEntity */ | ||
interface IRepository {} | ||
|
||
interface I { | ||
/** | ||
* Returns repository by repository class. | ||
* @template E of IEntity | ||
* @template T of IRepository<E> | ||
* @phpstan-param class-string<T> $className | ||
* @phpstan-return T | ||
*/ | ||
function getRepository(string $className): IRepository; | ||
} | ||
|
||
class User implements IEntity {} | ||
/** @implements IRepository<User> */ | ||
class UsersRepository implements IRepository {} | ||
|
||
function (I $model): void { | ||
assertType(UsersRepository::class, $model->getRepository(UsersRepository::class)); | ||
}; |
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