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

From: Date: Wed, 15 Jun 2016 17:38:57 +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-94017@lists.php.net to get a copy of this message
On 6/15/2016 12:27 PM, 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' > This is exactly how require is meant to work, just use include as Christoph said already. These are two distinct features for a reason. On 6/15/2016 12:27 PM, Alexander Lisachenko wrote: > 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. > We definitely need this but it cannot go into PHP 7.0. -- Richard "Fleshgrinder" Fussenegger

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.internals (#94017) next »