vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.57k stars 660 forks source link

Template is not correctly resolved #7897

Open VincentLanglet opened 2 years ago

VincentLanglet commented 2 years ago

https://psalm.dev/r/80114d436d

psalm expects DatagridInterface<ProxyQueryInterface> but IMHO, DatagridInterface<ProxyQueryInterface> should be expected (and is provided)

psalm-github-bot[bot] commented 2 years ago

I found these snippets:

https://psalm.dev/r/80114d436d ```php */ abstract class Admin implements AdminInterface { public function foo(): void { new DatagridMapper($this->getDatagridBuilder(), $this->getDatagrid(), $this); } /** @return DatagridBuilderInterface */ abstract public function getDatagridBuilder(); /** @return DatagridInterface> */ abstract public function getDatagrid(); } /** * @phpstan-template T of object */ interface DatagridInterface {} /** * @phpstan-template T of object */ interface DatagridBuilderInterface {} /** * @phpstan-template T of object */ interface ProxyQueryInterface {} /** * @phpstan-template T of object */ class DatagridMapper { /** * @phpstan-param DatagridBuilderInterface $datagridBuilder * @phpstan-param DatagridInterface> $datagrid * @phpstan-param AdminInterface $admin */ public function __construct( DatagridBuilderInterface $datagridBuilder, DatagridInterface $datagrid, AdminInterface $admin ) { } } ``` ``` Psalm output (using commit b5b5c20): ERROR: InvalidArgument - 16:57 - Argument 2 of DatagridMapper::__construct expects DatagridInterface>, DatagridInterface> provided ```