I have collections using IteratorAggregate interface. And I can't find a way how to type hint it properly that both Psalm and PhpStorm are satisfied.
Here is a simplified example. It has an AbstractCollection and one Collection, but there are actually multiple collections extending the AbstractCollection.
This example works fine for PhpStorm but Psalm complains about it.
https://psalm.dev/r/9a3fc1db43
I tried several things, but nothing really works. Any ideas how I can get proper type hinting in PhpStorm when iterating the collection, but at the same time have Psalm not complaining?
This should work: https://psalm.dev/r/24c1344df3
You missed the docblock on
AbstractCollection::getIterator().