-
-
Notifications
You must be signed in to change notification settings - Fork 946
Closed
Description
Bug report
When there is a nested generic parameter, resolution from subtype string-class is not done.
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 test(I $model): void {
$model->getRepository(UsersRepository::class);
}Results to Unable to resolve the template type T in call to method Nextras\Orm\Model\IModel::getRepository(). Changing the getRepository signature to @template T of IRepository (removed <E>) helps but its not correct and produce error about missing the IRepository generic parameter.
Code snippet that reproduces the problem
https://phpstan.org/r/4b0bfe9f-4e01-4067-b4fb-e65c11e9da57
Expected output
Ability to resolve return type to AuthorsRepository instance.
Reactions are currently unavailable