Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Tjerk Meesters
On 19 Jun, 2013, at 1:04 AM, Patrick Schaaf wrote: > > > var_dump(array_filter(['foo', '', 'bar'], 'strlen', true)); > > > > Warning: strlen() expects exactly 1 parameter, 2 given in - on line 1 > > > > Not only do we trigger the error handler (a large enough array causes a > > performance iss

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Peter Cowburn
On 18 June 2013 23:21, Sherif Ramadan wrote: > Are you saying that it's better to have familiarity over functionality? > > I'm not sure I agree with this premise of we shouldn't provide > better functionality just because it would make all the other poorly > written functions look bad. That's set

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Sherif Ramadan
On Tue, Jun 18, 2013 at 6:08 PM, Peter Cowburn wrote: > On 18 June 2013 18:24, Sherif Ramadan wrote: > >> > Nevertheless, I'd say go with a new array_filter_key() function, because >> > that permits using existing one-parameter functions like that strlen as >> a >> > callback, instead of forcing

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Peter Cowburn
On 18 June 2013 18:24, Sherif Ramadan wrote: > > Nevertheless, I'd say go with a new array_filter_key() function, because > > that permits using existing one-parameter functions like that strlen as a > > callback, instead of forcing two-parameter callback functions. > > > The current patch does n

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Leigh
On 18 June 2013 18:24, Sherif Ramadan wrote: > I suppose the order of the elements should remain $value, $key in the event > of ARRAY_FILTER_KEY | ARRAY_FILTER_VAL. > This is also the order already used for the callback of array_walk, so I think it makes sense to have some consistency. (Even if

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Sherif Ramadan
On Tue, Jun 18, 2013 at 1:04 PM, Patrick Schaaf wrote: > > > var_dump(array_filter(['foo', '', 'bar'], 'strlen', true)); > > > > Warning: strlen() expects exactly 1 parameter, 2 given in - on line 1 > > > > Not only do we trigger the error handler (a large enough array causes a > > performance is

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Leigh
On 18 June 2013 18:04, Patrick Schaaf wrote: > > Another alternative might be to go with a third argument to array_filter(), > but make that an integer with ORable constants ARRAY_FILTER_KEY, > ARRAY_FILTER_VAL - only one of them set calls with a single argument, both > set call with two arguments

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Patrick Schaaf
> var_dump(array_filter(['foo', '', 'bar'], 'strlen', true)); > > Warning: strlen() expects exactly 1 parameter, 2 given in - on line 1 > > 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

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Sherif Ramadan
On Tue, Jun 18, 2013 at 11:37 AM, Tjerk Anne Meesters 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-ar

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Sherif Ramadan
On Tue, Jun 18, 2013 at 11:28 AM, Levi Morrison wrote: > > > If `strlen` can't handle extra parameters then I'd say *that* is a real > problem, this PR aside. > I'm not sure how that's a real problem. All built in PHP functions specify a signature.

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Sherif Ramadan
On Tue, Jun 18, 2013 at 11:27 AM, Leigh wrote: > On 18 June 2013 00:20, Sherif Ramadan wrote: > >> I'm starting up a thread for discussion on Pull Request 287 >> https://github.com/php/php-src/pull/287 (allowing array keys to be passed >> to the callback function of array_filter through a third

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Tjerk Anne Meesters
On Tue, Jun 18, 2013 at 11:07 PM, Sherif Ramadan wrote: > On Tue, Jun 18, 2013 at 10:58 AM, Levi Morrison >wrote: > > > > > I'm starting up a thread for discussion on Pull Request 287 > >> https://github.com/php/php-src/pull/287 (allowing array keys to be > passed > >> to the callback function of

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Levi Morrison
On Tue, Jun 18, 2013 at 9:07 AM, Sherif Ramadan wrote: > > On Tue, Jun 18, 2013 at 10:58 AM, Levi Morrison > wrote: > >> >> I'm starting up a thread for discussion on Pull Request 287 >>> https://github.com/php/php-src/pull/287 (allowing array keys to be >>> passed >>> to the callback function of

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Leigh
On 18 June 2013 00:20, Sherif Ramadan wrote: > I'm starting up a thread for discussion on Pull Request 287 > https://github.com/php/php-src/pull/287 (allowing array keys to be passed > to the callback function of array_filter through a third optional boolean > argument). > Why not use array_filt

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Sherif Ramadan
On Tue, Jun 18, 2013 at 10:58 AM, Levi Morrison wrote: > > I'm starting up a thread for discussion on Pull Request 287 >> https://github.com/php/php-src/pull/287 (allowing array keys to be passed >> to the callback function of array_filter through a third optional boolean >> argument). I would lik

Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion]

2013-06-18 Thread Levi Morrison
> I'm starting up a thread for discussion on Pull Request 287 > https://github.com/php/php-src/pull/287 (allowing array keys to be passed > to the callback function of array_filter through a third optional boolean > argument). I would like to merge this into master and as discussed on IRC > it woul