提交的内容

This commit is contained in:
2025-05-12 15:45:02 +08:00
parent 629c4750da
commit b48c692775
3043 changed files with 34732 additions and 60810 deletions

30
vendor/guzzlehttp/psr7/src/UploadedFile.php vendored Executable file → Normal file
View File

@ -11,15 +11,15 @@ use RuntimeException;
class UploadedFile implements UploadedFileInterface
{
private const ERRORS = [
UPLOAD_ERR_OK,
UPLOAD_ERR_INI_SIZE,
UPLOAD_ERR_FORM_SIZE,
UPLOAD_ERR_PARTIAL,
UPLOAD_ERR_NO_FILE,
UPLOAD_ERR_NO_TMP_DIR,
UPLOAD_ERR_CANT_WRITE,
UPLOAD_ERR_EXTENSION,
private const ERROR_MAP = [
UPLOAD_ERR_OK => 'UPLOAD_ERR_OK',
UPLOAD_ERR_INI_SIZE => 'UPLOAD_ERR_INI_SIZE',
UPLOAD_ERR_FORM_SIZE => 'UPLOAD_ERR_FORM_SIZE',
UPLOAD_ERR_PARTIAL => 'UPLOAD_ERR_PARTIAL',
UPLOAD_ERR_NO_FILE => 'UPLOAD_ERR_NO_FILE',
UPLOAD_ERR_NO_TMP_DIR => 'UPLOAD_ERR_NO_TMP_DIR',
UPLOAD_ERR_CANT_WRITE => 'UPLOAD_ERR_CANT_WRITE',
UPLOAD_ERR_EXTENSION => 'UPLOAD_ERR_EXTENSION',
];
/**
@ -64,8 +64,8 @@ class UploadedFile implements UploadedFileInterface
$streamOrFile,
?int $size,
int $errorStatus,
string $clientFilename = null,
string $clientMediaType = null
?string $clientFilename = null,
?string $clientMediaType = null
) {
$this->setError($errorStatus);
$this->size = $size;
@ -104,7 +104,7 @@ class UploadedFile implements UploadedFileInterface
*/
private function setError(int $error): void
{
if (false === in_array($error, UploadedFile::ERRORS, true)) {
if (!isset(UploadedFile::ERROR_MAP[$error])) {
throw new InvalidArgumentException(
'Invalid error status for UploadedFile'
);
@ -113,7 +113,7 @@ class UploadedFile implements UploadedFileInterface
$this->error = $error;
}
private function isStringNotEmpty($param): bool
private static function isStringNotEmpty($param): bool
{
return is_string($param) && false === empty($param);
}
@ -137,7 +137,7 @@ class UploadedFile implements UploadedFileInterface
private function validateActive(): void
{
if (false === $this->isOk()) {
throw new RuntimeException('Cannot retrieve stream due to upload error');
throw new RuntimeException(\sprintf('Cannot retrieve stream due to upload error (%s)', self::ERROR_MAP[$this->error]));
}
if ($this->isMoved()) {
@ -163,7 +163,7 @@ class UploadedFile implements UploadedFileInterface
{
$this->validateActive();
if (false === $this->isStringNotEmpty($targetPath)) {
if (false === self::isStringNotEmpty($targetPath)) {
throw new InvalidArgumentException(
'Invalid path provided for move operation; must be a non-empty string'
);