Re: Throwing an Error for require expressions in PHP7.x

From: Date: Wed, 15 Jun 2016 10:52:05 +0000
Subject: Re: Throwing an Error for require expressions in PHP7.x
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-93999@lists.php.net to get a copy of this message
On 15.06.2016 at 12:27, Alexander Lisachenko wrote: > For PHP7 we have pretty errors for almost everything, even eval can throw a > ParseError exception, but not for the require expression, because it's > still producing an uncatchable fatal errors: > > try { > require('no.php'); > } catch (Throwable $e) { > echo 'Catch!'; > } finally { > echo 'Finally?'; > } > // Warning: require(no.php): failed to open stream: No such file or > directory > // Fatal error: require(): Failed opening required 'no.php' > > See https://3v4l.org/sQeAQ for live demo. What are the reasons > not to throw > Error here? Looks like an oversight for me. This had recently been reported as feature request, and my reply was: | With regard to your example: if a file is *required* and it can't | be included, it doesn't make much sense to go on. If on the other | hand the file is not really required, just include it. [1] <https://bugs.php.net/72089> -- Christoph M. Becker

« previous php.internals (#93999) next »