Skip to content

Nested generic argument bound is not correctly resolved to native type #4643

@hrach

Description

@hrach

Bug report

interface Entity {}

/** @template E of Entity */
interface Repository {
	/**
	 * @template F of E
	 * @param F $entity
	 * @return F
	 */
	function store(Entity $entity): Entity;
}

results in

PHPDoc tag @param for parameter $entity with type F is not subtype of native type Entity.
PHPDoc tag @return with type mixed is not subtype of native type Entity.

Code snippet that reproduces the problem

https://phpstan.org/r/4f86dceb-20e1-406d-92d4-eccd8da4c31b

Expected output

no error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions