On Tue, Jun 18, 2013 at 11:37 AM, Tjerk Anne Meesters <datib...@php.net>wrote:
> > > > The danger actually lurks in the cases whereby the second argument is > accepted and with that (sometimes radically) change the semantics of the > function; in fact, quite a few internal functions have this kind of > switch-by-argument behaviour, such as "array_keys" to randomly name one. > And admittedly, this function when my PR goes through ;-) > > > That is a worse outcome, sure, but there is still danger in the former scenario given that defaulting the callback to take two arguments causes the wrong result: var_dump(array_filter(['foo', '', 'bar'], 'strlen', true)); Warning: strlen() expects exactly 1 parameter, 2 given in - on line 1 Warning: strlen() expects exactly 1 parameter, 2 given in - on line 1 Warning: strlen() expects exactly 1 parameter, 2 given in - on line 1 array(0) { } Not only do we trigger the error handler (a large enough array causes a performance issue), but we also get back an empty array as a result. That's BC and performance loss that's simply unacceptable, so defaulting the behavior to pass the key is simply out of the question. > > -- > -- > Tjerk >