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: Request.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\RequestInterface;
[6] Fix | Delete
use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
[7] Fix | Delete
use YoastSEO_Vendor\Psr\Http\Message\UriInterface;
[8] Fix | Delete
/**
[9] Fix | Delete
* PSR-7 request implementation.
[10] Fix | Delete
*/
[11] Fix | Delete
class Request implements \YoastSEO_Vendor\Psr\Http\Message\RequestInterface
[12] Fix | Delete
{
[13] Fix | Delete
use MessageTrait;
[14] Fix | Delete
/** @var string */
[15] Fix | Delete
private $method;
[16] Fix | Delete
/** @var string|null */
[17] Fix | Delete
private $requestTarget;
[18] Fix | Delete
/** @var UriInterface */
[19] Fix | Delete
private $uri;
[20] Fix | Delete
/**
[21] Fix | Delete
* @param string $method HTTP method
[22] Fix | Delete
* @param string|UriInterface $uri URI
[23] Fix | Delete
* @param (string|string[])[] $headers Request headers
[24] Fix | Delete
* @param string|resource|StreamInterface|null $body Request body
[25] Fix | Delete
* @param string $version Protocol version
[26] Fix | Delete
*/
[27] Fix | Delete
public function __construct(string $method, $uri, array $headers = [], $body = null, string $version = '1.1')
[28] Fix | Delete
{
[29] Fix | Delete
$this->assertMethod($method);
[30] Fix | Delete
if (!$uri instanceof \YoastSEO_Vendor\Psr\Http\Message\UriInterface) {
[31] Fix | Delete
$uri = new \YoastSEO_Vendor\GuzzleHttp\Psr7\Uri($uri);
[32] Fix | Delete
}
[33] Fix | Delete
$this->method = \strtoupper($method);
[34] Fix | Delete
$this->uri = $uri;
[35] Fix | Delete
$this->setHeaders($headers);
[36] Fix | Delete
$this->protocol = $version;
[37] Fix | Delete
if (!isset($this->headerNames['host'])) {
[38] Fix | Delete
$this->updateHostFromUri();
[39] Fix | Delete
}
[40] Fix | Delete
if ($body !== '' && $body !== null) {
[41] Fix | Delete
$this->stream = \YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::streamFor($body);
[42] Fix | Delete
}
[43] Fix | Delete
}
[44] Fix | Delete
public function getRequestTarget() : string
[45] Fix | Delete
{
[46] Fix | Delete
if ($this->requestTarget !== null) {
[47] Fix | Delete
return $this->requestTarget;
[48] Fix | Delete
}
[49] Fix | Delete
$target = $this->uri->getPath();
[50] Fix | Delete
if ($target === '') {
[51] Fix | Delete
$target = '/';
[52] Fix | Delete
}
[53] Fix | Delete
if ($this->uri->getQuery() != '') {
[54] Fix | Delete
$target .= '?' . $this->uri->getQuery();
[55] Fix | Delete
}
[56] Fix | Delete
return $target;
[57] Fix | Delete
}
[58] Fix | Delete
public function withRequestTarget($requestTarget) : \YoastSEO_Vendor\Psr\Http\Message\RequestInterface
[59] Fix | Delete
{
[60] Fix | Delete
if (\preg_match('#\\s#', $requestTarget)) {
[61] Fix | Delete
throw new \InvalidArgumentException('Invalid request target provided; cannot contain whitespace');
[62] Fix | Delete
}
[63] Fix | Delete
$new = clone $this;
[64] Fix | Delete
$new->requestTarget = $requestTarget;
[65] Fix | Delete
return $new;
[66] Fix | Delete
}
[67] Fix | Delete
public function getMethod() : string
[68] Fix | Delete
{
[69] Fix | Delete
return $this->method;
[70] Fix | Delete
}
[71] Fix | Delete
public function withMethod($method) : \YoastSEO_Vendor\Psr\Http\Message\RequestInterface
[72] Fix | Delete
{
[73] Fix | Delete
$this->assertMethod($method);
[74] Fix | Delete
$new = clone $this;
[75] Fix | Delete
$new->method = \strtoupper($method);
[76] Fix | Delete
return $new;
[77] Fix | Delete
}
[78] Fix | Delete
public function getUri() : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[79] Fix | Delete
{
[80] Fix | Delete
return $this->uri;
[81] Fix | Delete
}
[82] Fix | Delete
public function withUri(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri, $preserveHost = \false) : \YoastSEO_Vendor\Psr\Http\Message\RequestInterface
[83] Fix | Delete
{
[84] Fix | Delete
if ($uri === $this->uri) {
[85] Fix | Delete
return $this;
[86] Fix | Delete
}
[87] Fix | Delete
$new = clone $this;
[88] Fix | Delete
$new->uri = $uri;
[89] Fix | Delete
if (!$preserveHost || !isset($this->headerNames['host'])) {
[90] Fix | Delete
$new->updateHostFromUri();
[91] Fix | Delete
}
[92] Fix | Delete
return $new;
[93] Fix | Delete
}
[94] Fix | Delete
private function updateHostFromUri() : void
[95] Fix | Delete
{
[96] Fix | Delete
$host = $this->uri->getHost();
[97] Fix | Delete
if ($host == '') {
[98] Fix | Delete
return;
[99] Fix | Delete
}
[100] Fix | Delete
if (($port = $this->uri->getPort()) !== null) {
[101] Fix | Delete
$host .= ':' . $port;
[102] Fix | Delete
}
[103] Fix | Delete
if (isset($this->headerNames['host'])) {
[104] Fix | Delete
$header = $this->headerNames['host'];
[105] Fix | Delete
} else {
[106] Fix | Delete
$header = 'Host';
[107] Fix | Delete
$this->headerNames['host'] = 'Host';
[108] Fix | Delete
}
[109] Fix | Delete
// Ensure Host is the first header.
[110] Fix | Delete
// See: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
[111] Fix | Delete
$this->headers = [$header => [$host]] + $this->headers;
[112] Fix | Delete
}
[113] Fix | Delete
/**
[114] Fix | Delete
* @param mixed $method
[115] Fix | Delete
*/
[116] Fix | Delete
private function assertMethod($method) : void
[117] Fix | Delete
{
[118] Fix | Delete
if (!\is_string($method) || $method === '') {
[119] Fix | Delete
throw new \InvalidArgumentException('Method must be a non-empty string.');
[120] Fix | Delete
}
[121] Fix | Delete
}
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function