Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106931 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13284 invoked from network); 12 Sep 2019 10:04:32 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 12 Sep 2019 10:04:32 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id BB2842D08EE for ; Thu, 12 Sep 2019 00:40:22 -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-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) (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 00:40:22 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id v38so23041910edm.7 for ; Thu, 12 Sep 2019 00:40:22 -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=jlvm2MiqfiksM4E1pCzvy6lG4MChVLIlxDdL3m6VPV0=; b=gnw4GZT9ZAxvTTYfVQibl53LWpSg+6ShffKEPO2n5c8CGi8iFm8SXBGQYmRFCeAr0O yInHrN/a5rXsIMA60MgV+e4f5bZIOXHnW4g6UuFWJtEhPhiXHzXS1xZ0vl/SYuqWMEvb ntr+eXTAhorUMZ9jVlBLrhrXBCsPkJbPB9ls1YScSMc/BQogNngdIlX+ekUB61WX93ED qTXVGXqlYtQFVEOa6+zR1sTSvsN14Y0PW62zwjjqBCyRQ140sBPPs4CdN9b9XL9bYvTJ qAnXuPgLxWp4tadAFT/kjss+OKJemw5t+PgtTfTy4PCSUOfODHsNeniI/7C860JNCihs oyDg== 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=jlvm2MiqfiksM4E1pCzvy6lG4MChVLIlxDdL3m6VPV0=; b=E2PYpwHjgu/hoFGoPG8p3jSUVz+TX7boFBcT/GDKR2XP3sjM4n6brwL9oTVBuy9bS1 wJN03m3m1fgAUXNyKlQJO8vAVuvY1Qw8TFIduZc3U4UQrVsxrVaLvtW0a/9bQESy37Dc O/k26WUK5SV3k6pkrTDg6rA7KnKe1KuHOxTjuv+gvMSQ3wuaINEyNfZfDla5opdbatLU aTjQv9bktP+s6BG4myzXeNOCr0UZS6QtmaQ5BGyaIgw1sng3BEWcfeijz+CFbVm9kDWE 4VKXTCILAGWpOHQrxGnC7yn24UbVcN9rrxq3kOGSX6dhb9AoYVTRZUqln4vaOu4EcVos KLyQ== X-Gm-Message-State: APjAAAXwMZAbmKcH4hYgk0UWCEJ1wsQF2guWzl52M7/T3GR5jQSCS7k2 GMsi+XB57rIWz9ux35DuREC4GMQZhKU= X-Google-Smtp-Source: APXvYqyeZUwNUh/6FJp13/0HBCiK/jucEu3GtsRCPp8NLUMahTAQzjQRyTg0MXKuPvJ356Njg3JvZw== X-Received: by 2002:a17:906:498c:: with SMTP id p12mr907509eju.289.1568274021123; Thu, 12 Sep 2019 00:40:21 -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 v10sm4607896eds.75.2019.09.12.00.40.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Sep 2019 00:40:20 -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 09:40:06 +0200 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Nikita Popov 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 10 sept. 2019 =C3=A0 15:31, Nikita Popov a = =C3=A9crit : >=20 > On Wed, Aug 28, 2019 at 11:33 AM Nikita Popov = wrote: >=20 >> Hi internals, >>=20 >> 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 = generating a >> notice is really quite mind-boggling. >>=20 >> I've prepared an RFC with some suggested classifications, though = there's >> room for bikeshedding here... >>=20 >> https://wiki.php.net/rfc/engine_warnings >>=20 >> Regards, >> Nikita >>=20 >=20 > Heads up: This RFC may go to vote tomorrow. >=20 > 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 =46rom 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, in 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