running PHP 7.3.7 in Cygwin 3.3.6, and SplFileObject::fwrite seems completely broken. to reproduce: $ touch bug.txt; chmod 0777 bug.txt; php -r '$o=new SplFileObject("bug.txt");var_dump($o->fwrite("test"));var_dump(error_get_last());' int(0) NULL so both fwrite() and error_get_last() failed to pick up that there was an error, but strace reveals: 67 487251 [main] php 1693 __set_errno: ssize_t write(int, const void*, size_t):1350 setting errno 9 60 487311 [main] php 1693 write: -1 = write(3, 0x6FFFFFE65BF8, 4), errno 9 errno 9 probably means: 9 EBADF Bad file descriptor.