Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:90089 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77944 invoked from network); 5 Jan 2016 13:50:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jan 2016 13:50:37 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.47 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.47 mail-wm0-f47.google.com Received: from [74.125.82.47] ([74.125.82.47:35387] helo=mail-wm0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 81/00-12097-C2ACB865 for ; Tue, 05 Jan 2016 08:50:36 -0500 Received: by mail-wm0-f47.google.com with SMTP id f206so23650652wmf.0 for ; Tue, 05 Jan 2016 05:50:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=waUgCdWy/yLQ5fqbASHHYLV04tEAiOoCIy1vNFNi/40=; b=iBsIlUJXCSrnbaQ2hd8SF8CmA3S1eLJ7DodR8wckc8CXa9tF65dfP/q61OZI7rKNvu oiNn6FVGRIA0+ObXPfa9zRRgdooZLwqOFo/BKyy8No3MLnQE2KRiB/IOQpSRYzyCG/lb 30Sf37rtmnyfbbfgC9wHzax7NM/5t0GB/zgksuJiq4U689P5S9YbeYh4vwI8y0N3hMs8 w2BExji+LuORBUZHDATRzy6wV2pP6bjp8zDR9RS5SfLM774bqwgVEkZDzdUVqXIk8NR3 42urD4Snj/Zq2yZR6+TXAO7hHzpD4VrOqTHf/+avwS/QkycFsSsxAtQg2TytqGAaTMHC IMAw== X-Received: by 10.28.224.134 with SMTP id x128mr4514819wmg.62.1452001833483; Tue, 05 Jan 2016 05:50:33 -0800 (PST) Received: from [192.168.0.137] ([93.188.182.58]) by smtp.googlemail.com with ESMTPSA id i3sm46986606wja.47.2016.01.05.05.50.32 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jan 2016 05:50:32 -0800 (PST) To: internals@lists.php.net References: Message-ID: <568BC9CF.1080000@gmail.com> Date: Tue, 5 Jan 2016 13:49:03 +0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Deprecation of the Error Control Operator (@ symbol) From: rowan.collins@gmail.com (Rowan Collins) Grzegorz Zdanowski wrote on 05/01/2016 12:27: > Before deprecating @ operator I think we should make a RFC which cover > unified setting to convert all E_* to exceptions (like > PhpWarningException). I know it's just a temporary solution, because > exception should be more specific, but it's a huge amount of work to > replace all errors and warnings with proper exceptions. This is definitely not the solution. I've seen this suggested a few times over the years, and every time people seem to miss a vital point: Warnings are not, in general, a fatal situation. A useful rule of thumb I heard for "should I throw an exception?" is "would I be happy to use a die() statement?" Even if you don't accept that, the main purpose of an exception is to force the code down a different path. (I've seen lots of discussions about exceptions being great because they have stack traces, but have never understood why any other mechanism couldn't also have those). In a few places, like the file-handle API, the Warning is accompanied by an invalid return value (usually false) and probably should be an exception - the code will definitely need to follow a different path, and dying would often be better than proceeding with an invalid handle (which will probably end up fatal later). But in many cases, an E_WARNING (or an E_NOTICE) really is just a warning - most code *doesn't* want to go down an alternative path, but it might want to log a message. In a few cases, code does want to go down a different path, and currently has to use the "error handler" infrastructure. In other cases, code wants to never log the message, and currently has to use the @ operator. The main problem, in my opinion, with the current system of "errors" (better called "messages") is that they provide only two pieces of identifying information: an integer representing severity, from a small list; and a string which may have placeholders, may change between versions, and does not come from a documented list. This means you can say "suppress everything with E_NOTICE severity" but not "suppress all array-assignment warnings"; and you can set up an error handler to convert everything into exceptions, but a handler to convert all file-handle warnings into exceptions would have to pattern-match every message string to identify them. The only way out of this that I can see is to replace the current string-based internal message APIs with something that forces the extension developer to pre-define a set of codes, and provide the substitution parameters for the error directly. This could then allow more information to be exposed to userland, and more granular stacking of handlers and configuration to mask off different types based on their codes. Regards, -- Rowan Collins [IMSoP]