Hey @azjezz, can you reproduce the issue on https://psalm.dev ?
I believe this is a minimal reproducer: https://psalm.dev/r/08b0d969e9
I found these snippets:
https://psalm.dev/r/08b0d969e9
<?php
namespace Psl\Collection;
use IteratorAggregate;
/**
* @template Tk of array-key
* @template Tv
* @extends IteratorAggregate<Tk, Tv>
*/
interface CollectionInterface extends IteratorAggregate {
/**
* @psalm-param Tk $k
* @psalm-return Tv
*/
public function at($k);
}
/**
* @template Tk of array-key
* @template Tv
*
* @extends CollectionInterface<Tk, Tv>
*/
interface AccessibleCollectionInterface extends CollectionInterface {}
/**
* @template Tk of array-key
* @template Tv
*
* @implements AccessibleCollectionInterface<Tk, Tv>
*/
abstract class Map implements AccessibleCollectionInterface
{
/**
* @psalm-param Tk $k
* @psalm-return Tv
*/
public function at($k) { /** @var Tv */ return 1; }
}
Psalm output (using commit 0411049):
ERROR: MoreSpecificImplementedParamType - 38:24 - Argument 1 of Psl\Collection\Map::at has the more specific type 'Tk:Psl\Collection\Map as array-key', expecting 'array-key' as defined by Psl\Collection\CollectionInterface::at
do you think it makes sense to revert https://github.com/vimeo/psalm/commit/6ed7a811463537d27f6669d6fd52946d0426621b?
I'm making sure that PSL always has a successful build.
The bug with Psl\Collection + generics has appeared multiple times here:
so in my opinion, Psl\Collection is a great real-world test case for generics in Psalm.
Agreed – I disabled tests because at the time there were bugs in PSL, now the shoe is on the other foot.
This was broken by https://github.com/vimeo/psalm/commit/15a5bd5e295d3dcf4f9e97fce9b6b6f3e01fed28
To be clear, though, this is a different bug than those others
This is one of those fun times where a "straightforward" refactor exposed an underlying bug that had been there for a while – that after stubs have been scanned, all explicit _and_ implicit (via inheritance) implemented interfaces were re-evaluated. It was the implicit ones that were causing trouble.
I've re-enabled PSL integration tests with 5fc2b4e04
Thank you for the quick fix.
but it seems there is still an issue with getIterator ( I see you added @psalm-suppress for it in the tests ), is the error valid? or awaiting a fix? https://github.com/azjezz/psl/runs/1498607963
Most helpful comment
This is one of those fun times where a "straightforward" refactor exposed an underlying bug that had been there for a while – that after stubs have been scanned, all explicit _and_ implicit (via inheritance) implemented interfaces were re-evaluated. It was the implicit ones that were causing trouble.
I've re-enabled PSL integration tests with 5fc2b4e04