https://phpstan.org/r/42818384-3047-4e86-9676-07f98ff0e5e7
<?php declare(strict_types = 1);
final class Item
{
}
/**
* @extends Traversable<Item>
*/
interface ItemListInterface extends Traversable
{
}
/**
* @implements IteratorAggregate<string>
*/
final class ItemList implements IteratorAggregate, ItemListInterface
{
public function getIterator()
{
return new ArrayIterator([]);
}
}
I understand that it's a rather specific case, and that phpstan does not "see" the connection between one interface being Traversable, and implementation class being an IteratorAggregate.
Ideally, we'd see that iterator types mismatch, but I'm pretty certain it's not simple.
Originally posted by @Steveb-p in #5221 (reply in thread)