https://psalm.dev/r/ce986a03b8
I think the issue raised by Psalm is not correct. While iterator_to_array does throw a TypeError in case of a non-scalar key (https://3v4l.org/BBOJF), the returned type of iterator_to_array(T, true) is never array<mixed, T>, it is array<array-key, T>.