<?php fwrite(resource $stream, string $data, ?int $length = null): int|false
<?php private function writeStringToStream(string $string, $target): void { if (@fwrite($target, $string) === false) { throw CannotWriteToTemporaryFile::new(error_get_last()); } }
<?php if (is_string($value)) { $fp = fopen('php://temp', 'rb+'); assert(is_resource($fp)); fwrite($fp, $value); fseek($fp, 0); $value = $fp; }