Throwing an Error for require expressions in PHP7.x

From: Date: Wed, 15 Jun 2016 10:27:56 +0000
Subject: Throwing an Error for require expressions in PHP7.x
Groups: php.internals 
Request: Send a blank email to internals+get-93995@lists.php.net to get a copy of this message
Hi, internals! 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. Can we also add FileNotFoundException and use it for all file functions to avoid silencing with "@" operator? Then require expression can throw an Error with nested FileNotFoundException. Thoughts?

« previous php.internals (#93995) next »