On 10/31/2016 12:25 AM, Yasuo Ohgaki wrote:
> It depends. Defining specific functions for a task could be bad design
> also. We do design basic functions with flags usually, too.
> 

I know that we have lots of them but they almost always end up in hard
to read and understand I-can-do-everything functions and their
implementation is also cluttered with branching.

On 10/31/2016 12:25 AM, Yasuo Ohgaki wrote:
> That said, dedicated functions for getting first/last key/value sounds
> good to me.
> 
> A agree. That's the reason why I state return value is problem. However,
> 
> if (empty($arr)) {
>   // Do something
> } else {
>   $first = array_first($arr);
> }
> 
> shouldn't be difficult.
> 
> We should raise error for nonsense usage. Programmers have to check
> empty()/isset() all the time anyway.
> 

I am an assert programmer, hence, I have no problem with an error in
such a case if others are fine with it.

@Rowan absolutely right, hence, if really needed:

```
function array_shift_key(array $array);

function array_pop_key(array $array);
```

-- 
Richard "Fleshgrinder" Fussenegger

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

Reply via email to