<?php error_clear_last();
$stream = @fopen($prefixedLocation, 'w+b');
if ( ! ($stream && false !== stream_copy_to_stream($contents, $stream) && fclose($stream))) {
$reason = error_get_last()['message'] ?? '';
throw UnableToWriteFile::atLocation($prefixedLocation, $reason);
}