Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../vendor_p.../guzzleht.../psr7/src
File: UploadedFile.php
<?php
[0] Fix | Delete
[1] Fix | Delete
declare (strict_types=1);
[2] Fix | Delete
namespace YoastSEO_Vendor\GuzzleHttp\Psr7;
[3] Fix | Delete
[4] Fix | Delete
use InvalidArgumentException;
[5] Fix | Delete
use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
[6] Fix | Delete
use YoastSEO_Vendor\Psr\Http\Message\UploadedFileInterface;
[7] Fix | Delete
use RuntimeException;
[8] Fix | Delete
class UploadedFile implements \YoastSEO_Vendor\Psr\Http\Message\UploadedFileInterface
[9] Fix | Delete
{
[10] Fix | Delete
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];
[11] Fix | Delete
/**
[12] Fix | Delete
* @var string|null
[13] Fix | Delete
*/
[14] Fix | Delete
private $clientFilename;
[15] Fix | Delete
/**
[16] Fix | Delete
* @var string|null
[17] Fix | Delete
*/
[18] Fix | Delete
private $clientMediaType;
[19] Fix | Delete
/**
[20] Fix | Delete
* @var int
[21] Fix | Delete
*/
[22] Fix | Delete
private $error;
[23] Fix | Delete
/**
[24] Fix | Delete
* @var string|null
[25] Fix | Delete
*/
[26] Fix | Delete
private $file;
[27] Fix | Delete
/**
[28] Fix | Delete
* @var bool
[29] Fix | Delete
*/
[30] Fix | Delete
private $moved = \false;
[31] Fix | Delete
/**
[32] Fix | Delete
* @var int|null
[33] Fix | Delete
*/
[34] Fix | Delete
private $size;
[35] Fix | Delete
/**
[36] Fix | Delete
* @var StreamInterface|null
[37] Fix | Delete
*/
[38] Fix | Delete
private $stream;
[39] Fix | Delete
/**
[40] Fix | Delete
* @param StreamInterface|string|resource $streamOrFile
[41] Fix | Delete
*/
[42] Fix | Delete
public function __construct($streamOrFile, ?int $size, int $errorStatus, string $clientFilename = null, string $clientMediaType = null)
[43] Fix | Delete
{
[44] Fix | Delete
$this->setError($errorStatus);
[45] Fix | Delete
$this->size = $size;
[46] Fix | Delete
$this->clientFilename = $clientFilename;
[47] Fix | Delete
$this->clientMediaType = $clientMediaType;
[48] Fix | Delete
if ($this->isOk()) {
[49] Fix | Delete
$this->setStreamOrFile($streamOrFile);
[50] Fix | Delete
}
[51] Fix | Delete
}
[52] Fix | Delete
/**
[53] Fix | Delete
* Depending on the value set file or stream variable
[54] Fix | Delete
*
[55] Fix | Delete
* @param StreamInterface|string|resource $streamOrFile
[56] Fix | Delete
*
[57] Fix | Delete
* @throws InvalidArgumentException
[58] Fix | Delete
*/
[59] Fix | Delete
private function setStreamOrFile($streamOrFile) : void
[60] Fix | Delete
{
[61] Fix | Delete
if (\is_string($streamOrFile)) {
[62] Fix | Delete
$this->file = $streamOrFile;
[63] Fix | Delete
} elseif (\is_resource($streamOrFile)) {
[64] Fix | Delete
$this->stream = new \YoastSEO_Vendor\GuzzleHttp\Psr7\Stream($streamOrFile);
[65] Fix | Delete
} elseif ($streamOrFile instanceof \YoastSEO_Vendor\Psr\Http\Message\StreamInterface) {
[66] Fix | Delete
$this->stream = $streamOrFile;
[67] Fix | Delete
} else {
[68] Fix | Delete
throw new \InvalidArgumentException('Invalid stream or file provided for UploadedFile');
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
/**
[72] Fix | Delete
* @throws InvalidArgumentException
[73] Fix | Delete
*/
[74] Fix | Delete
private function setError(int $error) : void
[75] Fix | Delete
{
[76] Fix | Delete
if (\false === \in_array($error, \YoastSEO_Vendor\GuzzleHttp\Psr7\UploadedFile::ERRORS, \true)) {
[77] Fix | Delete
throw new \InvalidArgumentException('Invalid error status for UploadedFile');
[78] Fix | Delete
}
[79] Fix | Delete
$this->error = $error;
[80] Fix | Delete
}
[81] Fix | Delete
private static function isStringNotEmpty($param) : bool
[82] Fix | Delete
{
[83] Fix | Delete
return \is_string($param) && \false === empty($param);
[84] Fix | Delete
}
[85] Fix | Delete
/**
[86] Fix | Delete
* Return true if there is no upload error
[87] Fix | Delete
*/
[88] Fix | Delete
private function isOk() : bool
[89] Fix | Delete
{
[90] Fix | Delete
return $this->error === \UPLOAD_ERR_OK;
[91] Fix | Delete
}
[92] Fix | Delete
public function isMoved() : bool
[93] Fix | Delete
{
[94] Fix | Delete
return $this->moved;
[95] Fix | Delete
}
[96] Fix | Delete
/**
[97] Fix | Delete
* @throws RuntimeException if is moved or not ok
[98] Fix | Delete
*/
[99] Fix | Delete
private function validateActive() : void
[100] Fix | Delete
{
[101] Fix | Delete
if (\false === $this->isOk()) {
[102] Fix | Delete
throw new \RuntimeException('Cannot retrieve stream due to upload error');
[103] Fix | Delete
}
[104] Fix | Delete
if ($this->isMoved()) {
[105] Fix | Delete
throw new \RuntimeException('Cannot retrieve stream after it has already been moved');
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
public function getStream() : \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
[109] Fix | Delete
{
[110] Fix | Delete
$this->validateActive();
[111] Fix | Delete
if ($this->stream instanceof \YoastSEO_Vendor\Psr\Http\Message\StreamInterface) {
[112] Fix | Delete
return $this->stream;
[113] Fix | Delete
}
[114] Fix | Delete
/** @var string $file */
[115] Fix | Delete
$file = $this->file;
[116] Fix | Delete
return new \YoastSEO_Vendor\GuzzleHttp\Psr7\LazyOpenStream($file, 'r+');
[117] Fix | Delete
}
[118] Fix | Delete
public function moveTo($targetPath) : void
[119] Fix | Delete
{
[120] Fix | Delete
$this->validateActive();
[121] Fix | Delete
if (\false === self::isStringNotEmpty($targetPath)) {
[122] Fix | Delete
throw new \InvalidArgumentException('Invalid path provided for move operation; must be a non-empty string');
[123] Fix | Delete
}
[124] Fix | Delete
if ($this->file) {
[125] Fix | Delete
$this->moved = \PHP_SAPI === 'cli' ? \rename($this->file, $targetPath) : \move_uploaded_file($this->file, $targetPath);
[126] Fix | Delete
} else {
[127] Fix | Delete
\YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::copyToStream($this->getStream(), new \YoastSEO_Vendor\GuzzleHttp\Psr7\LazyOpenStream($targetPath, 'w'));
[128] Fix | Delete
$this->moved = \true;
[129] Fix | Delete
}
[130] Fix | Delete
if (\false === $this->moved) {
[131] Fix | Delete
throw new \RuntimeException(\sprintf('Uploaded file could not be moved to %s', $targetPath));
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
public function getSize() : ?int
[135] Fix | Delete
{
[136] Fix | Delete
return $this->size;
[137] Fix | Delete
}
[138] Fix | Delete
public function getError() : int
[139] Fix | Delete
{
[140] Fix | Delete
return $this->error;
[141] Fix | Delete
}
[142] Fix | Delete
public function getClientFilename() : ?string
[143] Fix | Delete
{
[144] Fix | Delete
return $this->clientFilename;
[145] Fix | Delete
}
[146] Fix | Delete
public function getClientMediaType() : ?string
[147] Fix | Delete
{
[148] Fix | Delete
return $this->clientMediaType;
[149] Fix | Delete
}
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function