> > That is one the cases I meant. Also this is a bug in the user code. I can > imagine doing it on purpose for performance reasons (if the file is > created/deleted by other apps) tho'. > flock is what should be used here.
flock doesn't protect from other failures, such as a fread()ing a file located on NFS. As it stands now, @ may still useful to mute warnings and throw exceptions instead. The other solution today is to set up a temporary error handler before calling the native function, and restore the previous error handler right after, such as here <https://github.com/brick/std/blob/master/src/Internal/ErrorCatcher.php>. This allows to get the error message, but might incur a small performance penalty. IMO, @ can be safely removed the day PHP converts current warnings to exceptions. On Thu, 7 Feb 2019 at 02:32, Pierre Joye <pierre....@gmail.com> wrote: > On Thu, Feb 7, 2019, 8:07 AM Girgias <george.bany...@gmail.com wrote: > > > > > The most common case which comes to mind is to suppress erros while file > > reading. > > Because even if you check a file exists it could be deleted inbetween the > > check and the > > read command. As you can see this is even written in the documentation > [1] > > > > Best regards > > > > George Peter Banyard > > > > [1] https://secure.php.net/manual/en/function.fopen.php > > > > That is one the cases I meant. Also this is a bug in the user code. I can > imagine doing it on purpose for performance reasons (if the file is > created/deleted by other apps) tho'. > flock is what should be used here. > > best, > Pierre > > > > > >