ouzo
ouzo copied to clipboard
`FluentArray.skip()` and `limit()` leak `array_slice()` implementation detail
If you run this
$array = [
'Key' => 'One',
10 => 'Two',
20 => 'Three'
];
//when
$result = FluentArray::from($array)->limit(2)->toArray();
The resulting array is ['Key' => 'One', 0 => 'Two'], which doesn't make any sense. Same for skip(). (array_slice() reindexes integer keys, but keeps string keys -.-)
What should be done now is:
-
limit()andskip()should preserve keys (addtrueflag toarray_slice()) - this probably makes more sense -
limit()andskip()should reindex the array (usearray_values())