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

Templated values loose \Countable information #3412

Closed
LeSuisse opened this issue Jun 8, 2020 · 1 comment · Fixed by phpstan/phpstan-src#229
Closed

Templated values loose \Countable information #3412

LeSuisse opened this issue Jun 8, 2020 · 1 comment · Fixed by phpstan/phpstan-src#229

Comments

@LeSuisse
Copy link

LeSuisse commented Jun 8, 2020

Bug report

Issue seems to happen since 0.12.26.
A templated type is not considered \Countable even if the type extends \Countable.

Code snippet that reproduces the problem

<?php declare(strict_types = 1);

interface A extends Countable
{
}

/**
 * @template T of A
 */
class B
{
	/**
	 * @phpstan-var T
	 */
	public $a;
	
	public function getCount(): int
	{
		return count($this->a);
	}
}

https://phpstan.org/r/a5df5f9a-1be8-441d-8643-165916ddf7c7

Expected output

No error.

@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 May 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant