Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generic with explicit argument as template type bound #2928

Closed
hrach opened this issue Jan 29, 2020 · 4 comments
Closed

Generic with explicit argument as template type bound #2928

hrach opened this issue Jan 29, 2020 · 4 comments
Labels
Milestone

Comments

@hrach
Copy link
Contributor

hrach commented Jan 29, 2020

Bug report

Using generic type as template bound doesn't accept explicit generic argument.

https://phpstan.org/r/93677d60-da20-4a8f-b6c7-071e017ca6f4

/** @template E */
interface Foo {}

interface A {
	/**
	 * @template T of Foo<string>
	 * @param T $a
	 */
	function x($a): void;
}

Currently gives Method A::x() has parameter $a with generic interface Foo but does not specify its types: E

@ondrejmirtes
Copy link
Member

This type of bound is not supported yet, so the correct message should be something like this: https://phpstan.org/r/6c670ced-f96b-4903-a37b-fb57679f08a6

@ondrejmirtes
Copy link
Member

Hi, I'm thinking about implementing this. Can you outline the difference in behaviour between these two examples and why would you use the first one? Ideally show me some differences and expected output with \PHPStan\dumpType($expr);, thanks.

/** @template E */
interface Foo {}

interface A {
	/**
	 * @template T of Foo<string>
	 * @param T $a
	 */
	function x($a): void;
}

And:

/** @template E */
interface Foo {}

interface A {
	/**
	 * @param Foo<string> $a
	 */
	function x($a): void;
}

@ondrejmirtes
Copy link
Member

Implemented: phpstan/phpstan-src@e671cc0

Please test the hell out of this :)

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants