$filename = $matches[4] ?? '';
if (!empty($filename)) {
- $files[$name] = self::fetchFileData($stream, $boundary, $headers, $filename);
+ $files[$name] = static::fetchFileData($stream, $boundary, $headers, $filename);
return ['variables' => $variables, 'files' => $files];
} else {
$variables = self::fetchVariables($stream, $boundary, $headers, $name, $variables);
return ['variables' => $variables, 'files' => $files];
}
- private static function fetchFileData($stream, string $boundary, array $headers, string $filename)
+ protected static function fetchFileData($stream, string $boundary, array $headers, string $filename)
{
$error = UPLOAD_ERR_OK;
$lastLine = null;
while (($chunk = fgets($stream, 8096)) !== false && strpos($chunk, $boundary) !== 0) {
if ($lastLine !== null) {
- if (fwrite($fileHandle, $lastLine) === false) {
+ if (!fwrite($fileHandle, $lastLine)) {
$error = UPLOAD_ERR_CANT_WRITE;
break;
}
}
if ($lastLine !== null && $error !== UPLOAD_ERR_CANT_WRITE) {
- if (fwrite($fileHandle, rtrim($lastLine, "\r\n")) === false) {
+ if (!fwrite($fileHandle, rtrim($lastLine, "\r\n"))) {
$error = UPLOAD_ERR_CANT_WRITE;
}
}