On Tue, Apr 8, 2025, at 10:53, Daikaras wrote:
> On 4/5/2025 6:51 PM, Niels Dossche wrote:
> > Hi internals
> >
> > I'm opening the discussion for the RFC "array_first() and array_last()".
> > https://wiki.php.net/rfc/array_first_last
> >
> > Kind regards
> > Niels
>
>
> -1 because returning null
for empty arrays is still wrong. Whatever
> similar behavior exists should be corrected to throw ValueError
in the
> future. Just my 2c.
>
I’ve always viewed arrays as an infinite field of nulls. The only time this isn’t true is when
you use array_key_exists() or care about the warnings (which make it less useful, IMHO). When you
treat it as an infinite field of nulls, you get some interesting mathematical/computational
properties you can exploit. Trying to treat it as a map/indexed-array is when you start running into
weird problems.
— Rob