Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116365 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 69167 invoked from network); 15 Nov 2021 11:11:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Nov 2021 11:11:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D4F18180540 for ; Mon, 15 Nov 2021 04:06:40 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 15 Nov 2021 04:06:40 -0800 (PST) Received: by mail-ua1-f52.google.com with SMTP id t13so34281270uad.9 for ; Mon, 15 Nov 2021 04:06:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=r8QAD/lZjJYJAknD5rkDnoBSec9ec+0DmpDKNrlddxE=; b=ccNtpx/7A4QI82UBp1HHyweVRc3uQ1xeOG3usX+6m6Uo97nHfBfr+VT9GZS+ve5Zmo dONCs3jTYcn/efD/hM5shnISHK7qaPggR8Je3ys3rXAr3ncUTgLfJSJFSlTxxvqSYp6K PRH2I7WKRl5Dyy4sa+t3ySt6/+0VqAWYv6N9ja+AgdJWJ4MrtFRDOTgqiaqOs5ejQlWz slXyC6ab0jESiO+Tm9ZfkYseFWn/CB3je06jFb1sr4bHUAow5pKAVE3+c2sxSxL1rz93 eLC7pZVMmQYf5Plh/cdbJTccIpPXJns1SnriE+JKXIQ1pDYe9aI5DRy7jyvaY5U4EZ0e xsXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=r8QAD/lZjJYJAknD5rkDnoBSec9ec+0DmpDKNrlddxE=; b=eSTMypZy9EuVT1X9Brs9wAgI7u6PtDGhvT8NB1wT3vnO8GUh2ZtAq0PpFuQfkz88mV v518zkoNLCSjnnBChHufEtPALEll+v1P+trFwhMVSR2UwdaBrP+xQjyG7YVDIqjae8EB npkDHWWr1ArpRK5w9PQxPOvhoweWMjv8KKWCPWeYI4yPBGUso8WG2v4pLcHhGeBMtziJ gz7hLo/EaV7ae61ivg1zxG1ZYJSyN6XlGpvHi1jX0D7AeVe4J5ZmZqCqScp+mtwN0JMW GuPM28n2JGnQ3Hmz63uUdcElS+/LjsIbiATJRK/ns5Rq2d1bv4LGHIK09fZPiOCug3Ih ZZIA== X-Gm-Message-State: AOAM532lbhWv4VwaWoLWttTpUsYSLe5Q3aoy34i5/XhnFe78gMSCUCcq gUrv724pKUK6Eewj0rqXceK3K91WSb/V3WX3sO0= X-Google-Smtp-Source: ABdhPJx23Rs+zaP7UxWqGTRH2MOiRu29GM41SVzwd0hjuHS1R/WoLsxuS4or4ZHXLFjyib3LtfMzqcjs44VesVbXPxo= X-Received: by 2002:a67:dc86:: with SMTP id g6mr42019545vsk.8.1636977999474; Mon, 15 Nov 2021 04:06:39 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 15 Nov 2021 13:06:28 +0100 Message-ID: To: Rowan Tommins Cc: PHP Internals Content-Type: multipart/alternative; boundary="00000000000029f3e005d0d2a459" Subject: Re: [PHP-DEV] Finer control of diagnostics (deprecations, notices, and warnings) From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --00000000000029f3e005d0d2a459 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable pon., 15 lis 2021 o 13:03 Micha=C5=82 Marcin Brzuchalski < michal.brzuchalski@gmail.com> napisa=C5=82(a): > Hi Rowan, > > pon., 15 lis 2021 o 12:34 Rowan Tommins > napisa=C5=82(a): > >> Hi all, >> >> Concerns have been raised a few times recently about adding new warnings >> and deprecation notices, particularly: >> >> * That code bases with many instances of a particular pattern see a lot >> of noise when a message is added >> * That library maintainers face pressure to fix deprecations from users >> who don't want to see those messages in their logs >> >> I don't think "stop adding new diagnostics to PHP" is a good solution to >> these problems, and have thought of two ideas which might improve >> things; both need refinement, but I hope can at least act as discussion >> starters. >> >> >> The first idea is directory-level error_reporting configuration. >> >> In principle, this would be very simple: a mechanism (ini setting or >> function) that lets a user specify a different error_reporting level for >> all code compiled from a particular directory. The most common use I >> foresee is reducing reporting in third-party libraries, e.g. >> >> error_reporting=3DE_ALL >> error_reporting[*/vendor/*]=3DE_ERROR+E_WARNING >> > > IMO this screams for comments regarding > modules/packages/assemblies however called > where error_reporting could be controlled by vendors. > Personally, I think that given feature users would add whole vendor > directory, > since the vendor/package directory is not fixed, > may change - which in essence may go out of control and silently invoke a > waterfall of unexpected errors. > > >> This would hopefully reduce pressure on maintainers to fix deprecation >> notices as soon as they appear, because they would no longer be >> cluttering the user's logs. >> >> >> The second idea is diagnostic codes or categories. >> >> This is more complicated, because it requires classifying all existing >> diagnostics to add extra information, but would allow users to act >> differently on specific messages. They might suppress them, downgrade >> Warnings to Notices, or even upgrade Notices to Warnings - as they might >> with rules in an IDE or Static Analysis tool. >> >> As an extension, the @ operator could be enhanced to suppress a specific >> diagnostic, so that the following would give an "undefined variable" >> warning, but be silent about the file not existing: >> >> @{FILE_NOT_FOUND}fopen($undefinedVariable, 'r'); >> > > This proposal allows to silence errors in certain statements but instead > of extending silence operator > personally, I'd prefer to enable statement-level attributes and shape the= m > in an opt-in manner. > Instead of proposing new syntax backward incompatible like this: > > $fp =3D @{FILE_NOT_FOUND}fopen($undefinedVariable, 'r'); > > introduce statement level attributes which can be backward compatible whe= n > in one line > > $fp =3D > #[SupressErrors(E_WARNING)] > fopen($undefinedVariable, 'r'); > My apologies this won't work for 8.0 and 8.1 since there are no statement-level attributes and the online attribute as a comment hack works only for <8.0 versions. Regards, --00000000000029f3e005d0d2a459--