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

From: Date: Tue, 18 Jun 2013 15:07:24 +0000
Subject: Re: PR 287 - added use_keys argument to array_filter() [Discussion]
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-67718@lists.php.net to get a copy of this message
On Tue, Jun 18, 2013 at 10:58 AM, Levi Morrison <morrison.levi@gmail.com>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 like to merge this into master and as discussed on IRC >> it would probably be a good idea to startup a discussion and make sure >> there aren't any objections or clarifications not yet voiced. >> >> The patch has no BC because the third argument is optional and defaults to >> false. Personally, I have always thought it would be a good idea to be >> able >> to get the keys into the array_filter callback since I've stumbled across >> a >> few scenarios where that would have made things easier. >> >> I'm not sure if there are any particular down sides to this option being >> added, but none that I can find. It currently passes all tests in master >> and works as expected. >> >> Thoughts, opinions, objections, concerns? >> >> > It might be considered a BC break, but I really think we should drop the > boolean argument; just have it pass the key as parameter 2 always. > See the discussion on github for that PR https://github.com/php/php-src/pull/287#issuecomment-14175109 unfortunately we can't do that as it will break lots of userspace code that might be doing stuff like array_filter(['foo','','bar'], 'strlen') where strlen only accepts a single argument and in those cases the result will be triggering lots of warnings and failed code.

« previous php.internals (#67718) next »