On 30/10/2016 12:07, Fleshgrinder wrote:
I think it makes much more sense to deprecate all of them and introduce
new ones that work in the way we want them to for several reasons.
`end()` and `reset()` would have to continue working as they do until
the next major release since people who use them might rely on the way
they work. This means in effect that nobody can make her PHP 7 code PHP
8 ready up front.

Instead we could directly introduce `array_first()` and `array_last()`
with the next feature release -- even if the others are not deprecated
-- and everyone can update their code or at least use it in new code.

I've always felt like these functions were "missing" from the language - there are a number of ways you *can* get the first or last item in an array, but all have side effects, because they're not designed for this purpose. It just so happens that - most of the time - reset() and end() have the smallest side effects.

I can't remember if it was an earlier discussion here, or somewhere else, that pointed to getting the first and last *key* as an extra use case worth considering. It's currently possible (if awkward) with key().

I think it would make sense to, in the same version:

- deprecate reset(), end(), each(), and key()
- introduce array_first(), array_last(), array_first_key() and array_last_key()
- document replacements for whatever other use cases we can find examples of

Doing them all at once makes the messaging much clearer - this family of functions is going to be removed; and here are the new functions you can start using immediately instead.

Regards,

--
Rowan Collins
[IMSoP]


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to