KnpMenu
KnpMenu copied to clipboard
Fix phpstan issue
Currently when creating a RecursiveItemIterator passing a new ArrayIterator, the Iterator is indexed by int.
$treeIterator = new \RecursiveIteratorIterator(
new RecursiveItemIterator(
new \ArrayIterator(array($menu))
), \RecursiveIteratorIterator::SELF_FIRST
);
So we got the following error:
Parameter #1 $iterator of class Knp\Menu\Iterator\RecursiveItemIterator constructor expects
Traversable<string, Knp\Menu\ItemInterface>, ArrayIterator<int, Knp\Menu\ItemInterface> given.
I can notice that the typehint in CurrentItemFilterIterator is ok: https://github.com/KnpLabs/KnpMenu/blob/master/src/Knp/Menu/Iterator/CurrentItemFilterIterator.php
This should then update the @extends and @implements, as the key type will be the one of the inner iterator. And the best way to solve it is by making it generic using TKey, reflecting that the original keys are preserved.
passing a new ArrayIterator, the Iterator is indexed by int.
this actually depends whether your array is indexed by int or by string