Stas, On Tue, Aug 7, 2012 at 1:46 AM, Stas Malyshev <smalys...@sugarcrm.com>wrote:
> Hi! > > > circumstance. If it's not, you should be checking for existence first > > (via file_exists() or is_readable(), etc)... > > This is exactly how we got into this mess with $x = > isset($a['x'])?$a['x']:null; > We're trying to get out of this mess and you're proposing to build > another mess just like that. A situation like that is not exceptional. It's null either way, therefore no exception should be thrown. (Which is why I said earlier that I wouldn't want most Notices to become exceptions)... > > errors, you can't just fread the return value. You *need* to change your > > execution flow based on that error. Therefore, it is exceptional. > > That's exactly what I am saying. Exceptions should not be a means of > flow control, and that's exactly what are you doing here. Exceptions by very definition are a means of flow control. That's their very purpose. The difference here is that it's a means of flow control when an error means you literally can't continue on in the current flow of execution (such as the fopen case). To continue the current flow would break lots of stuff, because it's expecting a resource. Therefore, the resource not being opened is exceptional... Anthony