Skip to content

Templated values loose \Countable information #3412

@LeSuisse

Description

@LeSuisse

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions