An array that was a list and had an element removed is no longer one, and json_encode silently emits an object instead of an array.
$ids = [101, 102, 103];
json_encode($ids); // [101,102,103]
unset($ids[1]);
json_encode($ids); // {"0":101,"2":103}
// the client's array parser now receives an object.
array_is_list($ids); // false
json_encode(array_values($ids)); // [101,103]
This reaches a client rather than a test, because the fixture that produced the response never had an element removed from the middle. array_values after any filtering is the fix and it belongs at the serialisation boundary rather than scattered through the code. The function is O(1) in the common case because the engine tracks packed arrays internally, which no userland check could match.