There is currently no formal way to specify a sequential array, or iterator.
I've taken to using array<integer,type> since arrays with integer indices in PHP are typically sequential. But others have adopted array<type>, even though this is actually equivalent to array<mixed,type>, which in no way restricts the indices.
After discussions, the best solution seems to be to release a new version of the spec, where array<type>, mixed<type>, ClassName<type> etc. all indicate that indices will be sequential integers. array<mixed,type> is still available for the rarer case where index type is flexible. Additionally, the other edge case of non-sequential integer indices can still be expressed with array<integer,type>.
array by itself will probably need to be assumed to be a sequence also - not sure how I feel about this one, as it differs from the native array type hint's restrictions.
There is currently no formal way to specify a sequential array, or iterator.
I've taken to using
array<integer,type>
since arrays with integer indices in PHP are typically sequential. But others have adoptedarray<type>
, even though this is actually equivalent toarray<mixed,type>
, which in no way restricts the indices.After discussions, the best solution seems to be to release a new version of the spec, where
array<type>
,mixed<type>
,ClassName<type>
etc. all indicate that indices will be sequential integers.array<mixed,type>
is still available for the rarer case where index type is flexible. Additionally, the other edge case of non-sequential integer indices can still be expressed witharray<integer,type>
.