Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83325 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55120 invoked from network); 20 Feb 2015 16:56:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2015 16:56:18 -0000 Authentication-Results: pb1.pair.com header.from=padraic.brady@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=padraic.brady@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.47 as permitted sender) X-PHP-List-Original-Sender: padraic.brady@gmail.com X-Host-Fingerprint: 209.85.213.47 mail-yh0-f47.google.com Received: from [209.85.213.47] ([209.85.213.47:46457] helo=mail-yh0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 11/A6-14173-F2767E45 for ; Fri, 20 Feb 2015 11:56:15 -0500 Received: by yhzz6 with SMTP id z6so4178860yhz.13 for ; Fri, 20 Feb 2015 08:56:13 -0800 (PST) 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:content-transfer-encoding; bh=ip52oocU1YhK1kSS3ri+vt+e86hJELmv/4wPszaZxsk=; b=wsof+Ii0ec3t6yROm6XNGyPzTKw+auurVNACKINBwQEWkx7jt0c4BZjjZ9ge2vg9wk CBMe+kbakOPuPaNPnWHQBbFqETgf/9Q1uhM3V1Rk5zLFaboxlfJCjjzRvy3BfsxGfF1n +48V/QBYJZ+kImnAy6lukWKOEzVqp09Itcy+e1preYbCfiKwW+vCJhAQalU5k438CgSm fr1YsqEHQunWU6LQan3heqa04CQPhyeZhbrCSUxtr/KRMBu0MNrLJf6tuknXkwEnLITZ VVzkoducHy2Hu0Tu72ChzWaFolt8z5sPoklQPUxePk/kLjenJ2M3rnSxNTjMVMJwsFks W+4Q== MIME-Version: 1.0 X-Received: by 10.170.52.14 with SMTP id 14mr8507208yku.77.1424451372879; Fri, 20 Feb 2015 08:56:12 -0800 (PST) Received: by 10.170.222.86 with HTTP; Fri, 20 Feb 2015 08:56:12 -0800 (PST) In-Reply-To: <1424447709.16516.2.camel@kuechenschabe> References: <1424447709.16516.2.camel@kuechenschabe> Date: Fri, 20 Feb 2015 16:56:12 +0000 Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: Niklas Keller , PHP Internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC][Discussion] In Operator From: padraic.brady@gmail.com (=?UTF-8?Q?P=C3=A1draic_Brady?=) On 20 February 2015 at 15:55, Johannes Schl=C3=BCter wrote: > On Fri, 2015-02-20 at 13:54 +0100, Niklas Keller wrote: >> Hi internals, >> >> "In Operator" is now in discussion phase. >> >> > This RFC adds a new in operator which simplifies contains checks for s= trings and arrays. >> > Currently, we have to usein_array($needle, $haystack, true) or strpos(= $haystack, $needle) !=3D=3D false. >> > These functions have a inconsistent parameter order, so it's hard to r= emember which is the right one >> > for each. The in operator makes these checks way more readable. Additi= onally, it also works for Traversable. >> >> https://wiki.php.net/rfc/in_operator > > | It uses strict comparison (=3D=3D=3D) for array values / instances of > | Traversable > > This might be nice but is inconsistent with other parts of the language > like switch statements. I think inconsistency is worse than this > inconvenience. I would be in favour of strict comparison. Being consistent with in_array() sounds great, but the loose comparison makes it difficult to use in certain use cases. A common usage would be a contains/in validator, for example, where loose comparisons can pass unwanted values depending on how it's written. I'm not fumbling in the dark, it has created a security issue in at least two frameworks. Since it's a new operator in isolation, tightening such rules would be welc= ome. Paddy -- P=C3=A1draic Brady http://blog.astrumfutura.com http://www.survivethedeepend.com