Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67724 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 70567 invoked from network); 18 Jun 2013 16:42:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Jun 2013 16:42:35 -0000 Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.177 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 74.125.82.177 mail-we0-f177.google.com Received: from [74.125.82.177] ([74.125.82.177:55821] helo=mail-we0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 1D/F0-00171-AFD80C15 for ; Tue, 18 Jun 2013 12:42:34 -0400 Received: by mail-we0-f177.google.com with SMTP id m19so3545163wev.22 for ; Tue, 18 Jun 2013 09:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=x+8wgJQPjNreAxK64GVcaOL2MoFK0J8pFCpSN6F46pE=; b=kpZP0jGVZ0YiiZZuohoI/79FOjhw8vKVS2EYjSjQiF/bTQ/9YrtnyIzd8otoLaWbrm 1fePZkfTm47PbO70j6tskyqqdXmvcrhM4nstsK68djHk+Mb9xdRnPj8Mq1fPAVloERty 9aqd2Y845J00OFA2lpE3c+rWLhmZw24SGx4NczCel+lAccqASm1tZeRpyvdSBwvn1WDm 8ozSl7mRX5TFO1XJaPDYFdwY+T1neFFJMjUvy8VyJntX0QBkFWYIM8XkPtQ4dVDhsx43 rBg2BRBSQlQs3WyA+bWzsi2lCxN235HgEkbgx1gX0QLywOhX2uoM1ZVFL0ChXv/RPCua +fjA== MIME-Version: 1.0 X-Received: by 10.180.20.46 with SMTP id k14mr8186010wie.14.1371573751095; Tue, 18 Jun 2013 09:42:31 -0700 (PDT) Received: by 10.227.156.201 with HTTP; Tue, 18 Jun 2013 09:42:31 -0700 (PDT) In-Reply-To: References: Date: Tue, 18 Jun 2013 12:42:31 -0400 Message-ID: To: Tjerk Anne Meesters Cc: Levi Morrison , PHP Internals Content-Type: multipart/alternative; boundary=bcaec53f34eb37aa2204df7066a3 Subject: Re: [PHP-DEV] PR 287 - added use_keys argument to array_filter() [Discussion] From: theanomaly.is@gmail.com (Sherif Ramadan) --bcaec53f34eb37aa2204df7066a3 Content-Type: text/plain; charset=ISO-8859-1 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-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 > --bcaec53f34eb37aa2204df7066a3--