Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108807 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 82926 invoked from network); 2 Mar 2020 16:22:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Mar 2020 16:22:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 28545180089 for ; Mon, 2 Mar 2020 06:40:58 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS1836 195.49.0.0/17 X-Spam-Virus: No X-Envelope-From: Received: from darkcity.gna.ch (darkcity.gna.ch [195.49.47.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 2 Mar 2020 06:40:56 -0800 (PST) Received: from flatter.home (unknown [IPv6:2a02:120b:2c4e:2460:f859:8635:f0ce:5d65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by darkcity.gna.ch (Postfix) with ESMTPSA id D2F776C151D; Mon, 2 Mar 2020 15:40:54 +0100 (CET) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3608.60.0.2.5\)) In-Reply-To: Date: Mon, 2 Mar 2020 15:40:54 +0100 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <627FD99D-C38A-495F-AF7B-C1D76D4B7591@cschneid.com> References: <3f615d82-a84b-697b-5c02-8d915270f92c@gmail.com> To: Marco Pivetta X-Mailer: Apple Mail (2.3608.60.0.2.5) Subject: Re: [PHP-DEV] [RFC] Increment/Decrement Fixes From: cschneid@cschneid.com (Christian Schneider) Am 02.03.2020 um 15:00 schrieb Marco Pivetta : > Overall against the RFC: `++` and `--` (prefix and suffix) are = supposed to > be used with numeric values, not with other types, as that makes = everything > only more confusing. >=20 > Code written (intentionally) to use `++` and `--` against non-numeric > values should **NOT** pass a code review, and I am sorry for those = that > have to maintain it if that happens. There are still those who find $wordcount[$word]++; useful enough to support both ++ on null as well as usage of = uninitialised array indices. Please respect this kind of code, it is out there and fully functional. > Changing the current behavior, regardless in which way, is a BC break: > might as well make the BC break useful: >=20 > RFC Proposal: `$a =3D null; $a--; $a =3D=3D=3D -1`. Let's make this an = explicit > TypeError instead. > RFC Proposal: `$a =3D null; --$a; $a =3D=3D=3D -1`. Let's make this an = explicit > TypeError instead. >=20 > RFC Proposal: `$a =3D true; $a++; $a =3D=3D=3D 2`. Let's make this an = explicit > TypeError instead. > RFC Proposal: `$a =3D true; ++$a; $a =3D=3D=3D 2`. Let's make this an = explicit > TypeError instead. > RFC Proposal: `$a =3D true; $a--; $a =3D=3D=3D 0`. Let's make this an = explicit > TypeError instead. > RFC Proposal: `$a =3D true; --$a; $a =3D=3D=3D 0`. Let's make this an = explicit > TypeError instead. >=20 > RFC Proposal: `$a =3D false; $a++; $a =3D=3D=3D 1`. Let's make this an = explicit > TypeError instead. > RFC Proposal: `$a =3D false; ++$a; $a =3D=3D=3D 1`. Let's make this an = explicit > TypeError instead. > RFC Proposal: `$a =3D false; $a--; $a =3D=3D=3D -1`. Let's make this = an explicit > TypeError instead. > RFC Proposal: `$a =3D false; --$a; $a =3D=3D=3D -1`. Let's make this = an explicit > TypeError instead. I don't care too much about -- but *if* you want to discourage ++ on = those types then make it E_STRICT, E_NOTICE or even E_WARNING. Similar for non-numeric increments. > In **addition** to that, we may propose removal of `++`, `--` and = similar > from non-numeric types (will lead to TypeError) like Andrea started in > https://wiki.php.net/rfc/invalid_strings_in_arithmetic >=20 > It makes no sense to keep a landmine there: let's get rid of it, = instead of > empowering it further (and breaking BC too, while doing so). I see your point and I can live with E_* but breaking well-defined and = functioning code because you don't like $null++ is wrong.=20 - Chris