close(); } } } static function writer($output, ?callable $func=null): FileWriter { $writer = new FileWriter($output); if ($func !== null) { try { $func($writer); } finally { $writer->close(); } } } static function tmpwriter($destdir=null, ?callable $func=null): TmpfileWriter { $tmpwriter = new TmpfileWriter($destdir); if ($func !== null) { try { $func($tmpwriter); } finally { $tmpwriter->close(); } } } static function shared($file, ?callable $func=null): SharedFile { $shared = new SharedFile($file); if ($func !== null) { try { $func($shared); } finally { $shared ->close(); } } } }