Re: Error warning change idea

From: Date: Thu, 29 Nov 2018 11:49:26 +0000
Subject: Re: Error warning change idea
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-103533@lists.php.net to get a copy of this message
On 29.11.2018 at 12:24, Dan Ackroyd wrote: > On Thu, 29 Nov 2018 at 09:59, Michał Brzuchalski <michal@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

« previous php.internals (#103533) next »