WordPress\AiClientDependencies\Nyholm\Psr7

UploadedFile::__construct │ public │ WP 1.0

Метод класса: UploadedFile{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$UploadedFile = new UploadedFile();
$UploadedFile->__construct( $streamOrFile, $size, $errorStatus, $clientFilename, $clientMediaType );
$streamOrFile(StreamInterface|строка|resource) (обязательный)
.
$size(int) (обязательный)
.
$errorStatus(int) (обязательный)
.
$clientFilename(строка|null)
.
По умолчанию: null
$clientMediaType(строка|null)
.
По умолчанию: null

Код UploadedFile::__construct() WP 7.1.2

public function __construct($streamOrFile, $size, $errorStatus, $clientFilename = null, $clientMediaType = null)
{
    if (\false === \is_int($errorStatus) || !isset(self::ERRORS[$errorStatus])) {
        throw new \InvalidArgumentException('Upload file error status must be an integer value and one of the "UPLOAD_ERR_*" constants');
    }
    if (\false === \is_int($size)) {
        throw new \InvalidArgumentException('Upload file size must be an integer');
    }
    if (null !== $clientFilename && !\is_string($clientFilename)) {
        throw new \InvalidArgumentException('Upload file client filename must be a string or null');
    }
    if (null !== $clientMediaType && !\is_string($clientMediaType)) {
        throw new \InvalidArgumentException('Upload file client media type must be a string or null');
    }
    $this->error = $errorStatus;
    $this->size = $size;
    $this->clientFilename = $clientFilename;
    $this->clientMediaType = $clientMediaType;
    if (\UPLOAD_ERR_OK === $this->error) {
        // Depending on the value set file or stream variable.
        if (\is_string($streamOrFile) && '' !== $streamOrFile) {
            $this->file = $streamOrFile;
        } elseif (\is_resource($streamOrFile)) {
            $this->stream = Stream::create($streamOrFile);
        } elseif ($streamOrFile instanceof StreamInterface) {
            $this->stream = $streamOrFile;
        } else {
            throw new \InvalidArgumentException('Invalid stream or file provided for UploadedFile');
        }
    }
}