Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106934 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 36459 invoked from network); 12 Sep 2019 11:51:50 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 12 Sep 2019 11:51:50 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 23EEE2D20A5 for ; Thu, 12 Sep 2019 02:27:42 -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,HTML_MESSAGE,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-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) (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:27:41 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id h2so16392684ljk.1 for ; Thu, 12 Sep 2019 02:27:41 -0700 (PDT) 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=cHydyZwtn22VL7icaCSw0XEUBINLSGFrNeDtqhJQJAs=; b=GieFaku6aeYX5WjC5bjFRF0t//r9MZkSiMLbXzIAfQ1QJbgtuLI/PQ68nPqS3b8KT1 QZ01oZX3KpeEm7Xzg/Kv9/HYB4tIUpilFzaVIqxG6bo+DeoTjajYsKxCs8TeeErF2Boq bUuMu2S5QVrlCDh0iwnhlCyTwGUYx6slayWWUYDgimRbOKqxNH/5/Cdk7FFf7VKadejq Gu3xRfPgxBBrqkp4ep4zfqp/JSasee/+j8+95HrItqCfxqwPtydSDcnLDsgvuJx9P+oM vjzkB/dTYq7jqoBybfWlK55bHyGvJMst2p0d7Q5XiInHGUxM8HwoFQ2R/Bx4rTXrVsV5 j76w== 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=cHydyZwtn22VL7icaCSw0XEUBINLSGFrNeDtqhJQJAs=; b=FkWZXB9CEuBw9GNNk02g8pidsZ0AWEn3T4QAJfGv8V8JFzA10Czl6Cn9S+baMV3DMt nQ4VmePLGpLAm5hh7rDJIs72mmRwmJ8IF5VrDvmmZlUODPgAdRxyntcl8xq6ujYHdQVl Nch5vNsGC4YqOP7sjguN5J0W3JYkWOy8rzAxvVwd8Np3gRaU12+LUK8Fti/vw8cHRral PO8SaitShEcHcBcQQapD15t2sblI5WOM6mmLXj7es1BdVgy6b/utZ9aKghd4GHwJxrof iXf+pZyQTmOHhjphld5bUcuOn/ZaFv1bP081d4OwdM0RizDFs32F+EAc1ha/varEPnv2 /Uug== X-Gm-Message-State: APjAAAVsCKu/XHOb8WTm41g5+u3M5Skisu2YlcE8vHJuqS+ezqCkaKAb 3QfVI4CBvGuFh4TuQO7NfhTgLCEiA8ZXcykyUss= X-Google-Smtp-Source: APXvYqx26TPol0nI7TO230ENbI5xY90fyZKd5/N6mu2rzJxtDI1Epv01dcYtvgejU5Orhrv1VBQ9iPzy+y02ZC81OiY= X-Received: by 2002:a2e:3a01:: with SMTP id h1mr8451640lja.171.1568280459454; Thu, 12 Sep 2019 02:27:39 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 12 Sep 2019 11:27:22 +0200 Message-ID: To: Claude Pache Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000b1abf2059257bfb8" X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] Reclassifying engine warnings From: nikita.ppv@gmail.com (Nikita Popov) --000000000000b1abf2059257bfb8 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Sep 12, 2019 at 9:40 AM Claude Pache wrote= : > > Le 10 sept. 2019 =C3=A0 15:31, Nikita Popov a = =C3=A9crit : > > > > On Wed, Aug 28, 2019 at 11:33 AM Nikita Popov > wrote: > > > >> Hi internals, > >> > >> I think it's time to take a look at our existing warnings & notices in > the > >> engine, and think about whether their current classification is still > >> appropriate. Error conditions like "undefined variable" only generatin= g > a > >> notice is really quite mind-boggling. > >> > >> I've prepared an RFC with some suggested classifications, though there= 's > >> room for bikeshedding here... > >> > >> https://wiki.php.net/rfc/engine_warnings > >> > >> Regards, > >> Nikita > >> > > > > Heads up: This RFC may go to vote tomorrow. > > > > Nikita > > > I have objections to those two reclassifications: > > * Undefined offset: %d =E2=80=94 Notice =E2=86=92 Warning > * Undefined index: %d =E2=80=94 Notice =E2=86=92 Warning > > > From experience, having to dutifully initialise each and every key in an > array is burdensome. I understand the rationale of enforcing that in some > coding standard; but whether those particular missing index should be > considered as unexpected (therefore deserving a Warning) is mostly a > question of coding style. > > This is in principle a similar issue as using uninitialised variables, > which, as noted in this thread, is a perfectly accepted coding pattern in > some languages (the issue being distinct from *undeclared* variables). I > say =E2=80=9Cin principle=E2=80=9D, because a perfectly reasonable coding= style may choose > to enforce initialisation of variables, but not of array keys. > > PHP has the advantage of supporting various coding styles. We should give > the opportunity to the users to say declaratively (and precisely) what, i= n > their coding style, is considered as acceptable, e.g. > > declare( > uninitialized_variables: error > uninitilalized_index: none > ); > > of course, possibly at a package-level declare. That would, for example, > enable people to place legacy code in lax mode and chose a stricter mode > for new code, even letting the precise notion of strictness vary with > fashion without having to review working code written two years ago. > > That said, as long as those issues are handled as errors (as in: > set_error_handler()) rather than exceptions, one may write a proper error > handler that does the distinction (I do that). However, an error handler > has the disadvantage of being global, making difficult the integration of > code written with differing coding standards. > > =E2=80=94Claude > Hi Claude, I have split off the question of undefined array keys into a separate section, which will be voted separately. I generally agree that ignoring undefined array key notices can be a legitimate coding style choice (while I would very much disagree that the same is true for undefined variables) -- though ultimately I think it is best to handle this with a custom error handler (which can check whether the error originated from your own codebase), rather than through a blanket suppression of notices. In line with that thinking I don't think it matters overly much whether it's a notice or warning for the purposes of suppression. But I also don't feel particularly strongly about having this case as a warning either, especially with the error_reporting=3DE_ALL defau= lt in PHP 8. Nikita --000000000000b1abf2059257bfb8--