Re: Deprecation of the Error Control Operator (@ symbol)

From: Date: Tue, 05 Jan 2016 02:52:43 +0000
Subject: Re: Deprecation of the Error Control Operator (@ symbol)
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-90043@lists.php.net to get a copy of this message
Hi Bishop, > On Dec 31, 2015, at 3:48 PM, Bishop Bettini <bishop@php.net> wrote: > > I am -1 on removing @ for 7.x series. But, I would be in favor of all > changes that remove unnecessary error messages or add functionality to > better work with error messages. In my mind, those are requisite steps > before removing @. > I am also very much in agreement with this. There are many conditions where a warning or other error is raised with no way to test for the condition that will trigger the error. Before the @ can be removed, either these errors need to be removed or they need to become an exception that can be caught. For example, I have the following code for writing to a non-blocking stream (assume $resource is a stream socket resource and $data is a string): // Error reporting suppressed since fwrite() emits E_WARNING if the pipe is broken or the buffer is full. $written = @fwrite($resource, $data); if (false === $written) { $message = 'Failed to write to stream.'; if ($error = error_get_last()) { $message .= sprintf(' Errno: %d; %s', $error['type'], $error['message']); } throw new FailureException($message); } There is no way of knowing if the stream buffer is full before calling fwrite(), resulting in a warning and 0 being returned. IMO, just 0 should be returned without issuing a warning. Aaron Piotrowski https://trowski.com @trowski2002

« previous php.internals (#90043) next »