[#5432] Use array_shift instead of specific index access

- per @Maks3w