Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67725 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72648 invoked from network); 18 Jun 2013 17:04:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2013 17:04:26 -0000 Authentication-Results: pb1.pair.com header.from=bof@bof.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bof@bof.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain bof.de designates 80.242.145.70 as permitted sender) X-PHP-List-Original-Sender: bof@bof.de X-Host-Fingerprint: 80.242.145.70 mars.intermailgate.com Received: from [80.242.145.70] ([80.242.145.70:54924] helo=mars.intermailgate.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 67/61-00171-91390C15 for ; Tue, 18 Jun 2013 13:04:26 -0400 Received: (qmail 29915 invoked by uid 1009); 18 Jun 2013 19:04:22 +0200 Received: from 209.85.220.174 by mars (envelope-from , uid 89) with qmail-scanner-1.25-st-qms (clamdscan: 0.96.2/17370. spamassassin: 3.3.1. perlscan: 1.25-st-qms. Clear:RC:1(209.85.220.174):. Processed in 0.071402 secs); 18 Jun 2013 17:04:22 -0000 X-Antivirus-MYDOMAIN-Mail-From: bof@bof.de via mars X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:1(209.85.220.174):. Processed in 0.071402 secs Process 29908) Received: from mail-vc0-f174.google.com (gmail@bof.de@209.85.220.174) by mars.intermailgate.com with RC4-SHA encrypted SMTP; 18 Jun 2013 19:04:22 +0200 Received: by mail-vc0-f174.google.com with SMTP id kw10so3107194vcb.19 for ; Tue, 18 Jun 2013 10:04:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=qjiUvCxDCpDU1oTTXvm4UiXZAXZeDqcjS3PgPMO7Gwk=; b=PPvAZ2JEANillCtVBOVfeLR8wma8hnO5wIDPI1VhQEGRqVBHSWoAYyd9QQLGRS6KjL OodtKTnEtGDdZIellRGXRBCJR04o1zHhODxZeKkpCHV7tYbHUc61zgXK3++ki83XTAnS 4IBGJTl66SFJUDjCuBW+IH0GnsMHwfkwvkH5GNdJNtaOlUuc0eUolqzREMNa9CSN+Fgn HcK/ifAWumKq/AMtJgs0RY31ih5hXE0Ul77VRMUa5p+m+HHOItNfSfGc2b+cPGuCWcG6 luaIYFZpNjZQvSQ0fN0FpnDADyMcqsOevQ0RfI3QsC7U0ZOOybauJeGy2hKdDwYIW/FS szaA== MIME-Version: 1.0 X-Received: by 10.52.65.111 with SMTP id w15mr1036154vds.73.1371575060797; Tue, 18 Jun 2013 10:04:20 -0700 (PDT) Received: by 10.52.91.241 with HTTP; Tue, 18 Jun 2013 10:04:20 -0700 (PDT) Received: by 10.52.91.241 with HTTP; Tue, 18 Jun 2013 10:04:20 -0700 (PDT) In-Reply-To: References: Date: Tue, 18 Jun 2013 19:04:20 +0200 Message-ID: To: Sherif Ramadan Cc: internals , Tjerk Anne Meesters , Levi Morrison Content-Type: multipart/alternative; boundary=20cf307f3b444822ea04df70b4da Subject: Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion] From: bof@bof.de (Patrick Schaaf) --20cf307f3b444822ea04df70b4da Content-Type: text/plain; charset=ISO-8859-1 > 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 performance loss that's simply unacceptable, so defaulting the > behavior to pass the key is simply out of the question. Existing code won't pass that third, true, argument to array_filter(), and thus will not break. 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. 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. best regards Patrick --20cf307f3b444822ea04df70b4da--