On 29.11.2018 at 12:24, Dan Ackroyd wrote:

> On Thu, 29 Nov 2018 at 09:59, Michał Brzuchalski <mic...@brzuchalski.com> 
> wrote:
>>
>> I don't really know if it fits here but some weeks ago I was thinking about
>> annotations with "@" prefix
>> ....
>>
>> Which might work as supress all errors except fatal errors.
>>
>> Does that sound like a solution at all?
>> The developer then has full controll on what errors are suppressed or not..
> 
> I was thinking along similar lines a while ago:
> https://gist.github.com/Danack/5ae0b1b1ce30a0d785dd
> 
> The reason I never formally suggested it as an RFC is that I think
> it's doubling down on the wrong solution.
> 
> The vast majority of places where errors/warning are used currently,
> could either be just removed or have the result of the function be
> changed to be a tuple of the current result, and an error
> flag/message.
> 
> [$result, $error] = foo($bar);
> if ($error !== null) {
>   // something went wrong.
> }
> // $result is usable

If a function issues a warning and returns some value indicating
failure, we should consider to let the function throw an exception
instead.  Typical cases would be getimagesize(), fopen() and
password_hash(), for instance.

-- 
Christoph M. Becker

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to