Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:84944 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88641 invoked from network); 15 Mar 2015 22:17:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Mar 2015 22:17:20 -0000 Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.54 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.54 mail-pa0-f54.google.com Received: from [209.85.220.54] ([209.85.220.54:33957] helo=mail-pa0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E4/43-06614-FE406055 for ; Sun, 15 Mar 2015 17:17:20 -0500 Received: by pacwe9 with SMTP id we9so45234115pac.1 for ; Sun, 15 Mar 2015 15:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=lYompEmtG3eLNyqttJA/kjv3q0yPJB5M/6/Lfwm4E84=; b=rz3iutfxPLpEZvPX7I3D+ycf/soGqP47htTPpJAG/UWkrPR7YX1z/Cum4PPHtVzAN2 /ovtpEehDCxTM2B0mQXTX2MpE7cLuw/dasAsP+2V2EgPQyXv657cfLb2mPvoZ+jF7cFN e3PqqRR8141g1w1uSyaVx9nxrTS1O13ItFrrYBXIuuCSzmW/vko1d8IFDAyzHZFjaPVk zQNiFVEzJifdJCpcloXYiN+thTZDIXcnxc0kOVTgEGRweq3GieFtKPAyTYb6+Bz2Ikxg ceCa7KB33IG94X0G46v1yFcAOYJbJKDXCOmFiA1wxEaDq2EQibehTN99Gcu58/ZtvvJy OW/w== X-Received: by 10.66.136.48 with SMTP id px16mr93698535pab.89.1426457837002; Sun, 15 Mar 2015 15:17:17 -0700 (PDT) Received: from Stas-Air.local ([24.32.31.168]) by mx.google.com with ESMTPSA id m1sm10657982pdo.65.2015.03.15.15.17.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Mar 2015 15:17:15 -0700 (PDT) Message-ID: <550604EA.8050508@gmail.com> Date: Sun, 15 Mar 2015 15:17:14 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Niklas Keller CC: PHP Internals References: <5504EF9D.1000707@gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC][PRE-VOTE] In Operator From: smalyshev@gmail.com (Stanislav Malyshev) Hi! >> I think this operator is unnecessary - we already have perfectly good >> function that does the same. > > If they were "perfectly good", ... I think you forgot to finish your argument here. >> a set of values. Since efficient implementation of the set in PHP would >> have the value being sought as key, "in" would be useless, unless much >> slower iterative implementation is chosen. > > We already have a language construct here that's not a function call: isset. I'm pretty sure you misunderstood my argument. I am not arguing against introducing operators and language constructs in the language in general, I am well aware that more than one exists. I am arguing this particular operator duplicates a function and promotes wrong patterns. > >> Also, because it includes different (and inconsistent) implementation >> for strings, if you have ("foo" in $bar === true) , you don't know if >> $bar is an array that includes string "foo" or a string that has "foo" >> as a substring. I don't think it's good that operator would mix these >> two cases. > > It's different for strings, yes, but where's the inconsistency? The inconsistency is that for array, it's "has $foo as a sub-variable", i.e. there's $x so that $bar[$x] returns "foo". For string, it's not $x that $bar[$x] returns "foo", but $x so that substr($bar, $x, strlen("foo")) returns "foo". Worse yet, you never know which case is it. > A common user case would probably be checking user input against a set > of values. As others already mentioned in the discussion there have That's exactly what I am saying - checking against set of values by putting them into plain array and comparing them one by one is not a very good pattern, especially when set of values has non-negligible size. > been security issues using non-strict in_array in the past. in_array has strict option since... well, forever. If somebody doesn't know about it and has security problems, why do you assume he would know about your operator? -- Stas Malyshev smalyshev@gmail.com