Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116364 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 67785 invoked from network); 15 Nov 2021 11:09:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Nov 2021 11:09:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B6809180540 for ; Mon, 15 Nov 2021 04:03:43 -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-f50.google.com (mail-ua1-f50.google.com [209.85.222.50]) (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:03:40 -0800 (PST) Received: by mail-ua1-f50.google.com with SMTP id n6so17708998uak.1 for ; Mon, 15 Nov 2021 04:03: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=C+5iQTuNEaD7PfBkpv9ova3IKHM0ISjpmXNx0gGUvik=; b=ZDWUzl6fPZOp834/Z5SGSR4JkFAyZXeq0LLWXEFUZeI9ikFaKZB81xxf/tQNHZrZtW 8TmYDTCdKVGvLDBvRRdYT+iR3nLg0QYbBPYsY2mv0EnMJnG5fu+Bt03Z3uENqm0Cmv3f wbi+7PhxtBlYvUxophiRLNVcgrqe4bC/mx6Kvx0eQvGMRCdZ8IiYjVlUzH2YGO7wtdMP MBJlHLUsG72+fgFehK7IvhtuPqpdUlvD4W6t306u3JvNDqViZ8Y+RFqbkF2s7I3FyXTi aQRU3Xx5t7l20xc3yDxpHCR6IHiI1xLhWuUURaihjbxWbtGL05I6ITQ9EfVYW/lN2rPV UHXw== 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=C+5iQTuNEaD7PfBkpv9ova3IKHM0ISjpmXNx0gGUvik=; b=c1E5JokuAV60woAvlhRQB6xhMahwtHE+CWY6/J85oQu4bNvAkyoDUoOYfR181FHC0j VCjS5RVUv43NqE9CHiVdIG3RK+jZJYmfEJhqOjW2rhQ3XaThstMDhbIUZRCrSZa7MxHS WM3nmhZPPDhZJBQOOTtECY54xAh0h7+7hLiuknbgJnC9fmT5Q5ZYhMXHAmLh1Yf5OxP+ VIomtoiUFnB9sK4uvXxKY01zfqKq1NNmpg+Lwlkq6oPCj9TsHxUaUJaHk1i31U3fVKVq 1Kpp1nkvYN1Q4U+qhHjLibSZ0vHnpc0aIEhTyqYGJWDEtWgOQb3U4fTos40ShaQyoXd9 ONyw== X-Gm-Message-State: AOAM532CIllBi25pIqvfr5tEw8W9PU5a1NM2Wv7PzGIEBwT3aa/prYkV 4XeIZ22/1IyRhFpyRqG6SAcZ4VxaBaJFGSN/Ddu264Kt4NMwpA== X-Google-Smtp-Source: ABdhPJyeePhVLfDg+brnPmyARwh0iu7z1obMbg8ehZAPo5NxlroXvwI6Vh09ID1nUxhjAfAs8e6zppEwGKNYMnWnnEc= X-Received: by 2002:a67:fb05:: with SMTP id d5mr42222411vsr.41.1636977819526; Mon, 15 Nov 2021 04:03:39 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 15 Nov 2021 13:03:28 +0100 Message-ID: To: Rowan Tommins Cc: PHP Internals Content-Type: multipart/alternative; boundary="0000000000007027fe05d0d29918" 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?=) --0000000000007027fe05d0d29918 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 them 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 when in one line $fp =3D #[SupressErrors(E_WARNING)] fopen($undefinedVariable, 'r'); What do you think? Cheers, Micha=C5=82 Marcin Brzuchalski --0000000000007027fe05d0d29918--