Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:110256 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 47498 invoked from network); 22 May 2020 18:17:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 May 2020 18:17:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D9FA41804CB for ; Fri, 22 May 2020 09:56:22 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, 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-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (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 ; Fri, 22 May 2020 09:56:22 -0700 (PDT) Received: by mail-wm1-f54.google.com with SMTP id f13so9251516wmc.5 for ; Fri, 22 May 2020 09:56:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=QJA+Lu+JR4E98FCtSIgHWAvouiy8KrWoRKB1dyKQQ1I=; b=BQ0ouEKoLJGmbgtapOwVqGLWmW2yv0EKggWcQY1PwLOSa2ITCl83Imt6aSixb9RsDc FzBO8dFTXQGXKnp0OgKCuzM50du50LisyanFba1VSf6uh/rpdAO/9/UGgwPEQRB/oCHY B8nfnEcy1aBfSWpFymnt/EO5YZHjZnoQaQz0NUI3pQ3SKuIHlzotsi+6P4gs6BqLTBrq e/Xt1E7MkRL0gxHEtFT0/TQEr65gBFHWnIvxCRF5YrLA2t/kSLxU0yg4dc0gh0kY7w3D OM8UGaJQoWadUqNRde7tfmPcPEeHMX4+O3xexPHmJZsopBIs3wuQQM8UJ1Z9dvnwHkcy Q1KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=QJA+Lu+JR4E98FCtSIgHWAvouiy8KrWoRKB1dyKQQ1I=; b=nDENKJYpr0lPd27PUOl71vpCuOVY8s+KH/zaJD+smGvCm2wMCprxXe5swzjmAmSzxj vdSeqS2+ZV3PfpHgokzXtDgayYW3i7sCWWHbqgm5gI+K0hCcagRlUeYosBjpxD6cg6CT zJ9DuAxCh+Wxj9PwI2WH2w3IOkyw7jkxutb91GXLkgKri6kt6B2fr1T34j1UDCuVDKd+ 9JKAd9A/NZ3T7QNyA5e9p8T7LKy4j1uGAVl0FglNfw76Cf/+uVTTYnMIIfn4+ROJDBSX ea94iWfBhvuoaU6e6HTb7PasjGUEIs+hv6AnLMn6eVBbMb7/79QpRYGArU01hHQdGtdc Mfdw== X-Gm-Message-State: AOAM533KWMkFkQ/WMCqAVoQKiqQLDxjnzw+0rvbawTu0d7TyN1nmLhWc 8DHDHQpgTqLec54quFArGIE3Tdfe X-Google-Smtp-Source: ABdhPJw+nMFH/lWIE5YuZDK4uOI4GzXjqbHE00KMGt9OJ+Tp7WP0smAXhgqD9Ym5+NeiZfpln5lbcA== X-Received: by 2002:a1c:4909:: with SMTP id w9mr14131795wma.95.1590166577900; Fri, 22 May 2020 09:56:17 -0700 (PDT) Received: from [192.168.0.14] (cpc84253-brig22-2-0-cust114.3-3.cable.virginm.net. [81.108.141.115]) by smtp.googlemail.com with ESMTPSA id l12sm11061977wrh.20.2020.05.22.09.56.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 May 2020 09:56:17 -0700 (PDT) To: internals@lists.php.net References: Message-ID: <0819e254-c789-e3d6-b23d-08128f195953@gmail.com> Date: Fri, 22 May 2020 17:56:16 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] [RFC][DISCUSSION] Error Exceptions mode From: rowan.collins@gmail.com (Rowan Tommins) On 22/05/2020 17:08, Katie Volz wrote: > I want to start a discussion on an RFC to add a declare() statement to > convert all errors triggered within a file to exceptions. Hi Katie, Personally, I'm not a fan of promoting messages to exceptions in this way, because APIs designed to throw exceptions generally look rather different from ones designed to warn and continue, so blindly converting seems like putting a square peg in a round hole. However, I know people do it already, so will give my thoughts on the principle. My main concern is that it needs a tighter definition of "error", and possibly a configurable one. The snippet from the manual which you include in your draft RFC references the current global error_reporting setting. This makes sense with a global error handler, but less so for a per-file declare - it means the caller can choose whether exceptions are thrown, somewhat defeating the point. Perhaps the declare directive could take an error level as its argument, e.g. declare(error_exceptions=E_ALL-E_NOTICE)? Relatedly, you would need to define how this interacts with the @ (error suppression or "shut up") operator - would that force the code to run past a point that would otherwise throw an exception? Again, I think that choice should be taken away from the caller, otherwise the author needs to account for both modes, e.g. declare(error_exceptions=E_WARNING); try {     $fh = fopen($blah, $mode);     // if caller can suppress ErrorExceptions, we still need to check if $fh is false     // ... } catch ( ErrorException $e ) {     // the caller shouldn't actually care what happens, because we can catch it here } Other than that, there's the usual awkwardness of declare - it has to be set in each file, and new directives are errors in old versions of PHP. That doesn't necessarily mean we shouldn't use it for now, though. Regards, -- Rowan Tommins (né Collins) [IMSoP]