Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104529 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94678 invoked from network); 27 Feb 2019 11:44:06 -0000 Received: from unknown (HELO mail-wm1-f41.google.com) (209.85.128.41) by pb1.pair.com with SMTP; 27 Feb 2019 11:44:06 -0000 Received: by mail-wm1-f41.google.com with SMTP id q187so4905196wme.5 for ; Wed, 27 Feb 2019 00:30:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mg44+rYuGJE2YADIaDUeiLU5OX3aMhuRyFc9j9NT/aY=; b=KB0QF0BY/U6Jc/jHVD8T1XJliVxTWrIb6N4kHJOb3tiliJ6s1gwSe1f03ZK5SaoFu9 o0hUyN87FuKVhl8+s74eJu/Kt0R+JZBBEaUQG8DuMd4SGTl78qxeqvC9oYGhgUlm9MDv MpPv9RRENnIZy1Hjj8gtpK4gcr17m0M1MHyK68GwDbPADh4cDsaf3m9ojakdhagYaiL1 i1m7CS10gGQ/vV1HDw23yEAR6CPkLeNysEqzaO2mph21twtJo0qG2m824klnfvrMpQzI SpO9nIZMFc25iWuge8S4D6xr5Bq2qmUpR2soMBtqpLw1TI50gt6K4UlJORw6UbeLotSp S+xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mg44+rYuGJE2YADIaDUeiLU5OX3aMhuRyFc9j9NT/aY=; b=MVtjGf3xlNYq+Pnyq9VoJMKKX5gAAT5RzCPeRdxw3P6E5piAl8GVdLpnEYqO7NbcTp 6YRSB6iW9vz3WqW9OTj10/LAwVMMIalQY8yGSVEpKlYRjNx9Cm8JRBVAaDASBSXSSP+O 26pZdx30J3fbg6kokitkdyYdBPZKsNy0juEJZYMWgJTSoFCt6RyVGbprGImAY2PUlww8 ZMHSQFgmVTgoBCB6AbT1QmYt2Oljj0D/px7ZZBUp6kvP+P3gZD9Xb473jIwiRwz4f7zc vzGtp+PVFLqxuq6EGFbBnEnYC8RdjszwhP3IcBPD672UQwZGgXY66rqWSURLAa4C9Vy1 A/BQ== X-Gm-Message-State: AHQUAuZQlHXdysAjTB/mI2zY1ac8YbkmQO2zYn7ELFxSGBqNJZpPxk+h ZeMpU01SaGiXGmiXa6GbNNcUXVNytUmIIcxTQec= X-Google-Smtp-Source: AHgI3Iau5p3dpPQm6C5YPooYaUjCImRWpIv8dssO5EIHpx5PqFDl4txb6wAieWVmZOjGE8Pr0P57Z6WYHxq45ubKI10= X-Received: by 2002:a1c:6506:: with SMTP id z6mr1365803wmb.153.1551256241375; Wed, 27 Feb 2019 00:30:41 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 27 Feb 2019 10:30:15 +0200 Message-ID: To: "Kingsquare.nl - Robin Speekenbrink" Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary="000000000000390e940582dbfd04" Subject: Re: [PHP-DEV] [RFC] Saner string to number comparisons From: arvids.godjuks@gmail.com (Arvids Godjuks) --000000000000390e940582dbfd04 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable =D1=81=D1=80, 27 =D1=84=D0=B5=D0=B2=D1=80. 2019 =D0=B3. =D0=B2 10:06, Kings= quare.nl - Robin Speekenbrink < robin@kingsquare.nl>: > Op di 26 feb. 2019 om 13:27 schreef Nikita Popov : > > > Hi internals, > > > > I think it is well known that =3D=3D in PHP is a pretty big footgun. It > doesn't > > have to be. I think that type juggling comparisons in a language like P= HP > > have some merit, it's just that the particular semantics of =3D=3D in P= HP > make > > it so dangerous. The biggest WTF factor is probably that 0 =3D=3D "foob= ar" > > returns true. > > > > I'd like to bring forward an RFC for PHP 8 to change the semantics of = =3D=3D > > and other non-strict comparisons, when used between a number and a > string: > > > > https://wiki.php.net/rfc/string_to_number_comparison > > > > ... > > > > Regards, > > Nikita > > > > Dear All, > > From a user-space POV this is a very good way forward and I (personally) > really like the proposal of having a transitional period (7.4 anyone?) > > As of the 0 =3D=3D "" bit: I do think that an empty string is widespread > regarded as falsey-string... Thus 0 =3D=3D "" sould IMHO return true... > > Just my 2 cents, keep up the excellent Nikita! > (and everyone else ofcourse) > > Regards, > Robin > It's a bad idea to leave 0 =3D=3D "" - remember - we are dealing with strin= gs that come in via HTTP, so when you handle form input a 0 can be a valid input value, but an empty string is not. Sure, a =3D=3D=3D is better used here or empty(), but we should not leave edge cases like these. This is a string to a number comparison - it should trigger notice or error or whatever is designed to happen when "abc" =3D=3D= 123 is being done. --=20 Arv=C4=ABds Godjuks +371 26 851 664 arvids.godjuks@gmail.com Skype: psihius Telegram: @psihius https://t.me/psihius --000000000000390e940582dbfd04--