Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106935 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40744 invoked from network); 12 Sep 2019 12:06:03 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 12 Sep 2019 12:06:03 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 3E8102D20B1 for ; Thu, 12 Sep 2019 02:41:54 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: X-Spam-Virus: No Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 12 Sep 2019 02:41:53 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id f2so17001379edw.3 for ; Thu, 12 Sep 2019 02:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=CtPpTbFvGwLZ+SgogPWK+evMzIyfFOuO8+CT/W0CAuU=; b=du9gZ374ck546z2GFYUz9H/jWlZnEdJDU440fYxTHdZLJ8NQK6yCaLdieuuxNAMTK4 J53bKjdP1dA0B0hg6TZVnOtmQkAAXgQgPHC73GGNy5911XWr6MAFXdEmdOIB4UgVBCC9 UQJFveOQbdoBut/1B69vwRpVV0W57RXdXIN20w5si3jYvE9z+ufstIO3m2eFkS65IK5K eMECnv6k+GVmls8NTIfOGmSmk6XPuvOxxAmuVmsR8z0dBdSrUaLb79vYYA3DikqLOI+U CoIt3YnTvARdfUOepCU3QLgrs9hAJphuzEPYjEs0sdYqw4DTYeTn2q07rpXmg0p/gaAz vCCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=CtPpTbFvGwLZ+SgogPWK+evMzIyfFOuO8+CT/W0CAuU=; b=beRNHabhP0Eqb8GWIX0q0akaP686RIuExJ+dwcPa+Bd4E3rEplPoK5WYEgF4CRoh7k fTht+XTYO92AT+a6xHNEZc3akq/cRQRgk73Da5+L5YhCNJEYRZMEcvLl6Knv80jFDWIw 6YWk1begMiEwuqnqAI10GC50xVkR6SEpGSOupnef6DI6boF+bvJ+LtnFxbk8Q8PxWD6u NbsZTP/sP5KTi1+ZY+UxQDbMjDr6Kn+THtWAdRpptAu657wyoTPmfna1BkDKYo2DdYnG GZj2d2K88S1Ga4frpPDF1eS9exs1dMZBr+aMc8qyJFopgllSVAVFFNH68aC7+e8m78KX s9bw== X-Gm-Message-State: APjAAAUkCh2TyRexa6qx4IZc0r7S8xsFC+Sk2iMuYGOjXUJyh94wyDPM fhh1fGCohcZNIMkxVZ3kA2s= X-Google-Smtp-Source: APXvYqzF/Y09fHd7ZKs/nre4r/nGxQkmavQ98DKe5O1HLagH8s7Ayc6D1r7Ut/SzviiXnoYHObstZg== X-Received: by 2002:a17:906:3406:: with SMTP id c6mr33610774ejb.89.1568281312501; Thu, 12 Sep 2019 02:41:52 -0700 (PDT) Received: from [192.168.0.63] (84-75-30-51.dclient.hispeed.ch. [84.75.30.51]) by smtp.gmail.com with ESMTPSA id om24sm940983ejb.55.2019.09.12.02.41.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Sep 2019 02:41:52 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) In-Reply-To: Date: Thu, 12 Sep 2019 11:41:36 +0200 Cc: Nikita Popov , PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Stephen Reay X-Mailer: Apple Mail (2.3445.104.11) X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] Reclassifying engine warnings From: claude.pache@gmail.com (Claude Pache) > Le 12 sept. 2019 =C3=A0 10:17, Stephen Reay = a =C3=A9crit : >=20 >=20 >=20 > I=E2=80=99ve seen a number of people that have concerns about PHP = throwing actual errors (as opposed to notices) because they try to use a = variable/offset that doesn=E2=80=99t exist, and of course there is often = a proposal to have a declare statement or something similar, to allow = their =E2=80=9Ccode style=E2=80=9D to run without errors. >=20 >=20 > So, my proposal to the situation is to introduce a single declare that = solves that problem, once and for all. >=20 >=20 > declare(sloppy=3D1); >=20 >=20 > This would suppress any errors about undefined variables, array = offsets, would reverse the =E2=80=9Cbare words" change when encountering = an undefined constant, etc. Heck, for good measure this mode could even = re-implement register_globals and magic_quotes, because why not?=20 >=20 >=20 >=20 > If you want to write sloppy code, that is entirely your prerogative, = but please just own it for what it is, and stop pretending that it=E2=80=99= s some herculean task to either define variables/offsets first; or check = if they=E2=80=99re defined; or use an appropriate method to access them = that specifically allows for undefined variables/offsets (i.e. the ?? = and ??=3D operators) >=20 >=20 Declare(sloppy=3Dyeah) is not granular enough. To all: please, do = understand that everything is not black or white; this remark is not = directed specifically to that particular issue, this is an attitude I = see regularly on that mailing list. There is no such thing as =E2=80=9Cone true strict coding standard=E2=80=9D= and =E2=80=9Cone legacy lax coding standard=E2=80=9D. For instance: * As time passes, we learn by experience what features were plain = blunders (magic_quotes?), what features should have been more strict for = the sake of catching bugs without imposing too much burden on users, = what features could have been more strict, although that would impose to = write lot of boiler code, etc. This process does not belong exclusively = to some past dark age of sloppy and unsecure coding practices. * The degree of wanted strictness vary depending on occasions. For = example when I=E2=80=99m writing a throw-away script, some notices are = okay to indicate possible problems, but I=E2=80=99m not going to write = boilerplate code (or, worse, put a @ in front of everything) just for = the sake of silencing them. (But I *certainly* do not want stupid things = like mistyped constants converted to string literals.) On the other = hand, when I=E2=80=99m writing a critical part of an application, I am = careful to write down everything precisely, and having to write = explicitly and once for all that, yes, this precise variable must have = that default value, is a minimal part of the time passed to write, = re-read and review the code. =E2=80=94Claude=