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: Uri.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 YoastSEO_Vendor\GuzzleHttp\Psr7\Exception\MalformedUriException;
[5] Fix | Delete
use YoastSEO_Vendor\Psr\Http\Message\UriInterface;
[6] Fix | Delete
/**
[7] Fix | Delete
* PSR-7 URI implementation.
[8] Fix | Delete
*
[9] Fix | Delete
* @author Michael Dowling
[10] Fix | Delete
* @author Tobias Schultze
[11] Fix | Delete
* @author Matthew Weier O'Phinney
[12] Fix | Delete
*/
[13] Fix | Delete
class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerializable
[14] Fix | Delete
{
[15] Fix | Delete
/**
[16] Fix | Delete
* Absolute http and https URIs require a host per RFC 7230 Section 2.7
[17] Fix | Delete
* but in generic URIs the host can be empty. So for http(s) URIs
[18] Fix | Delete
* we apply this default host when no host is given yet to form a
[19] Fix | Delete
* valid URI.
[20] Fix | Delete
*/
[21] Fix | Delete
private const HTTP_DEFAULT_HOST = 'localhost';
[22] Fix | Delete
private const DEFAULT_PORTS = ['http' => 80, 'https' => 443, 'ftp' => 21, 'gopher' => 70, 'nntp' => 119, 'news' => 119, 'telnet' => 23, 'tn3270' => 23, 'imap' => 143, 'pop' => 110, 'ldap' => 389];
[23] Fix | Delete
/**
[24] Fix | Delete
* Unreserved characters for use in a regex.
[25] Fix | Delete
*
[26] Fix | Delete
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
[27] Fix | Delete
*/
[28] Fix | Delete
private const CHAR_UNRESERVED = 'a-zA-Z0-9_\\-\\.~';
[29] Fix | Delete
/**
[30] Fix | Delete
* Sub-delims for use in a regex.
[31] Fix | Delete
*
[32] Fix | Delete
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
[33] Fix | Delete
*/
[34] Fix | Delete
private const CHAR_SUB_DELIMS = '!\\$&\'\\(\\)\\*\\+,;=';
[35] Fix | Delete
private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26'];
[36] Fix | Delete
/** @var string Uri scheme. */
[37] Fix | Delete
private $scheme = '';
[38] Fix | Delete
/** @var string Uri user info. */
[39] Fix | Delete
private $userInfo = '';
[40] Fix | Delete
/** @var string Uri host. */
[41] Fix | Delete
private $host = '';
[42] Fix | Delete
/** @var int|null Uri port. */
[43] Fix | Delete
private $port;
[44] Fix | Delete
/** @var string Uri path. */
[45] Fix | Delete
private $path = '';
[46] Fix | Delete
/** @var string Uri query string. */
[47] Fix | Delete
private $query = '';
[48] Fix | Delete
/** @var string Uri fragment. */
[49] Fix | Delete
private $fragment = '';
[50] Fix | Delete
/** @var string|null String representation */
[51] Fix | Delete
private $composedComponents;
[52] Fix | Delete
public function __construct(string $uri = '')
[53] Fix | Delete
{
[54] Fix | Delete
if ($uri !== '') {
[55] Fix | Delete
$parts = self::parse($uri);
[56] Fix | Delete
if ($parts === \false) {
[57] Fix | Delete
throw new \YoastSEO_Vendor\GuzzleHttp\Psr7\Exception\MalformedUriException("Unable to parse URI: {$uri}");
[58] Fix | Delete
}
[59] Fix | Delete
$this->applyParts($parts);
[60] Fix | Delete
}
[61] Fix | Delete
}
[62] Fix | Delete
/**
[63] Fix | Delete
* UTF-8 aware \parse_url() replacement.
[64] Fix | Delete
*
[65] Fix | Delete
* The internal function produces broken output for non ASCII domain names
[66] Fix | Delete
* (IDN) when used with locales other than "C".
[67] Fix | Delete
*
[68] Fix | Delete
* On the other hand, cURL understands IDN correctly only when UTF-8 locale
[69] Fix | Delete
* is configured ("C.UTF-8", "en_US.UTF-8", etc.).
[70] Fix | Delete
*
[71] Fix | Delete
* @see https://bugs.php.net/bug.php?id=52923
[72] Fix | Delete
* @see https://www.php.net/manual/en/function.parse-url.php#114817
[73] Fix | Delete
* @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING
[74] Fix | Delete
*
[75] Fix | Delete
* @return array|false
[76] Fix | Delete
*/
[77] Fix | Delete
private static function parse(string $url)
[78] Fix | Delete
{
[79] Fix | Delete
// If IPv6
[80] Fix | Delete
$prefix = '';
[81] Fix | Delete
if (\preg_match('%^(.*://\\[[0-9:a-f]+\\])(.*?)$%', $url, $matches)) {
[82] Fix | Delete
/** @var array{0:string, 1:string, 2:string} $matches */
[83] Fix | Delete
$prefix = $matches[1];
[84] Fix | Delete
$url = $matches[2];
[85] Fix | Delete
}
[86] Fix | Delete
/** @var string */
[87] Fix | Delete
$encodedUrl = \preg_replace_callback('%[^:/@?&=#]+%usD', static function ($matches) {
[88] Fix | Delete
return \urlencode($matches[0]);
[89] Fix | Delete
}, $url);
[90] Fix | Delete
$result = \parse_url($prefix . $encodedUrl);
[91] Fix | Delete
if ($result === \false) {
[92] Fix | Delete
return \false;
[93] Fix | Delete
}
[94] Fix | Delete
return \array_map('urldecode', $result);
[95] Fix | Delete
}
[96] Fix | Delete
public function __toString() : string
[97] Fix | Delete
{
[98] Fix | Delete
if ($this->composedComponents === null) {
[99] Fix | Delete
$this->composedComponents = self::composeComponents($this->scheme, $this->getAuthority(), $this->path, $this->query, $this->fragment);
[100] Fix | Delete
}
[101] Fix | Delete
return $this->composedComponents;
[102] Fix | Delete
}
[103] Fix | Delete
/**
[104] Fix | Delete
* Composes a URI reference string from its various components.
[105] Fix | Delete
*
[106] Fix | Delete
* Usually this method does not need to be called manually but instead is used indirectly via
[107] Fix | Delete
* `Psr\Http\Message\UriInterface::__toString`.
[108] Fix | Delete
*
[109] Fix | Delete
* PSR-7 UriInterface treats an empty component the same as a missing component as
[110] Fix | Delete
* getQuery(), getFragment() etc. always return a string. This explains the slight
[111] Fix | Delete
* difference to RFC 3986 Section 5.3.
[112] Fix | Delete
*
[113] Fix | Delete
* Another adjustment is that the authority separator is added even when the authority is missing/empty
[114] Fix | Delete
* for the "file" scheme. This is because PHP stream functions like `file_get_contents` only work with
[115] Fix | Delete
* `file:///myfile` but not with `file:/myfile` although they are equivalent according to RFC 3986. But
[116] Fix | Delete
* `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
[117] Fix | Delete
* that format).
[118] Fix | Delete
*
[119] Fix | Delete
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.3
[120] Fix | Delete
*/
[121] Fix | Delete
public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment) : string
[122] Fix | Delete
{
[123] Fix | Delete
$uri = '';
[124] Fix | Delete
// weak type checks to also accept null until we can add scalar type hints
[125] Fix | Delete
if ($scheme != '') {
[126] Fix | Delete
$uri .= $scheme . ':';
[127] Fix | Delete
}
[128] Fix | Delete
if ($authority != '' || $scheme === 'file') {
[129] Fix | Delete
$uri .= '//' . $authority;
[130] Fix | Delete
}
[131] Fix | Delete
if ($authority != '' && $path != '' && $path[0] != '/') {
[132] Fix | Delete
$path = '/' . $path;
[133] Fix | Delete
}
[134] Fix | Delete
$uri .= $path;
[135] Fix | Delete
if ($query != '') {
[136] Fix | Delete
$uri .= '?' . $query;
[137] Fix | Delete
}
[138] Fix | Delete
if ($fragment != '') {
[139] Fix | Delete
$uri .= '#' . $fragment;
[140] Fix | Delete
}
[141] Fix | Delete
return $uri;
[142] Fix | Delete
}
[143] Fix | Delete
/**
[144] Fix | Delete
* Whether the URI has the default port of the current scheme.
[145] Fix | Delete
*
[146] Fix | Delete
* `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used
[147] Fix | Delete
* independently of the implementation.
[148] Fix | Delete
*/
[149] Fix | Delete
public static function isDefaultPort(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : bool
[150] Fix | Delete
{
[151] Fix | Delete
return $uri->getPort() === null || isset(self::DEFAULT_PORTS[$uri->getScheme()]) && $uri->getPort() === self::DEFAULT_PORTS[$uri->getScheme()];
[152] Fix | Delete
}
[153] Fix | Delete
/**
[154] Fix | Delete
* Whether the URI is absolute, i.e. it has a scheme.
[155] Fix | Delete
*
[156] Fix | Delete
* An instance of UriInterface can either be an absolute URI or a relative reference. This method returns true
[157] Fix | Delete
* if it is the former. An absolute URI has a scheme. A relative reference is used to express a URI relative
[158] Fix | Delete
* to another URI, the base URI. Relative references can be divided into several forms:
[159] Fix | Delete
* - network-path references, e.g. '//example.com/path'
[160] Fix | Delete
* - absolute-path references, e.g. '/path'
[161] Fix | Delete
* - relative-path references, e.g. 'subpath'
[162] Fix | Delete
*
[163] Fix | Delete
* @see Uri::isNetworkPathReference
[164] Fix | Delete
* @see Uri::isAbsolutePathReference
[165] Fix | Delete
* @see Uri::isRelativePathReference
[166] Fix | Delete
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4
[167] Fix | Delete
*/
[168] Fix | Delete
public static function isAbsolute(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : bool
[169] Fix | Delete
{
[170] Fix | Delete
return $uri->getScheme() !== '';
[171] Fix | Delete
}
[172] Fix | Delete
/**
[173] Fix | Delete
* Whether the URI is a network-path reference.
[174] Fix | Delete
*
[175] Fix | Delete
* A relative reference that begins with two slash characters is termed an network-path reference.
[176] Fix | Delete
*
[177] Fix | Delete
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
[178] Fix | Delete
*/
[179] Fix | Delete
public static function isNetworkPathReference(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : bool
[180] Fix | Delete
{
[181] Fix | Delete
return $uri->getScheme() === '' && $uri->getAuthority() !== '';
[182] Fix | Delete
}
[183] Fix | Delete
/**
[184] Fix | Delete
* Whether the URI is a absolute-path reference.
[185] Fix | Delete
*
[186] Fix | Delete
* A relative reference that begins with a single slash character is termed an absolute-path reference.
[187] Fix | Delete
*
[188] Fix | Delete
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
[189] Fix | Delete
*/
[190] Fix | Delete
public static function isAbsolutePathReference(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : bool
[191] Fix | Delete
{
[192] Fix | Delete
return $uri->getScheme() === '' && $uri->getAuthority() === '' && isset($uri->getPath()[0]) && $uri->getPath()[0] === '/';
[193] Fix | Delete
}
[194] Fix | Delete
/**
[195] Fix | Delete
* Whether the URI is a relative-path reference.
[196] Fix | Delete
*
[197] Fix | Delete
* A relative reference that does not begin with a slash character is termed a relative-path reference.
[198] Fix | Delete
*
[199] Fix | Delete
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
[200] Fix | Delete
*/
[201] Fix | Delete
public static function isRelativePathReference(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : bool
[202] Fix | Delete
{
[203] Fix | Delete
return $uri->getScheme() === '' && $uri->getAuthority() === '' && (!isset($uri->getPath()[0]) || $uri->getPath()[0] !== '/');
[204] Fix | Delete
}
[205] Fix | Delete
/**
[206] Fix | Delete
* Whether the URI is a same-document reference.
[207] Fix | Delete
*
[208] Fix | Delete
* A same-document reference refers to a URI that is, aside from its fragment
[209] Fix | Delete
* component, identical to the base URI. When no base URI is given, only an empty
[210] Fix | Delete
* URI reference (apart from its fragment) is considered a same-document reference.
[211] Fix | Delete
*
[212] Fix | Delete
* @param UriInterface $uri The URI to check
[213] Fix | Delete
* @param UriInterface|null $base An optional base URI to compare against
[214] Fix | Delete
*
[215] Fix | Delete
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.4
[216] Fix | Delete
*/
[217] Fix | Delete
public static function isSameDocumentReference(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri, \YoastSEO_Vendor\Psr\Http\Message\UriInterface $base = null) : bool
[218] Fix | Delete
{
[219] Fix | Delete
if ($base !== null) {
[220] Fix | Delete
$uri = \YoastSEO_Vendor\GuzzleHttp\Psr7\UriResolver::resolve($base, $uri);
[221] Fix | Delete
return $uri->getScheme() === $base->getScheme() && $uri->getAuthority() === $base->getAuthority() && $uri->getPath() === $base->getPath() && $uri->getQuery() === $base->getQuery();
[222] Fix | Delete
}
[223] Fix | Delete
return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === '';
[224] Fix | Delete
}
[225] Fix | Delete
/**
[226] Fix | Delete
* Creates a new URI with a specific query string value removed.
[227] Fix | Delete
*
[228] Fix | Delete
* Any existing query string values that exactly match the provided key are
[229] Fix | Delete
* removed.
[230] Fix | Delete
*
[231] Fix | Delete
* @param UriInterface $uri URI to use as a base.
[232] Fix | Delete
* @param string $key Query string key to remove.
[233] Fix | Delete
*/
[234] Fix | Delete
public static function withoutQueryValue(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri, string $key) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[235] Fix | Delete
{
[236] Fix | Delete
$result = self::getFilteredQueryString($uri, [$key]);
[237] Fix | Delete
return $uri->withQuery(\implode('&', $result));
[238] Fix | Delete
}
[239] Fix | Delete
/**
[240] Fix | Delete
* Creates a new URI with a specific query string value.
[241] Fix | Delete
*
[242] Fix | Delete
* Any existing query string values that exactly match the provided key are
[243] Fix | Delete
* removed and replaced with the given key value pair.
[244] Fix | Delete
*
[245] Fix | Delete
* A value of null will set the query string key without a value, e.g. "key"
[246] Fix | Delete
* instead of "key=value".
[247] Fix | Delete
*
[248] Fix | Delete
* @param UriInterface $uri URI to use as a base.
[249] Fix | Delete
* @param string $key Key to set.
[250] Fix | Delete
* @param string|null $value Value to set
[251] Fix | Delete
*/
[252] Fix | Delete
public static function withQueryValue(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri, string $key, ?string $value) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[253] Fix | Delete
{
[254] Fix | Delete
$result = self::getFilteredQueryString($uri, [$key]);
[255] Fix | Delete
$result[] = self::generateQueryString($key, $value);
[256] Fix | Delete
return $uri->withQuery(\implode('&', $result));
[257] Fix | Delete
}
[258] Fix | Delete
/**
[259] Fix | Delete
* Creates a new URI with multiple specific query string values.
[260] Fix | Delete
*
[261] Fix | Delete
* It has the same behavior as withQueryValue() but for an associative array of key => value.
[262] Fix | Delete
*
[263] Fix | Delete
* @param UriInterface $uri URI to use as a base.
[264] Fix | Delete
* @param (string|null)[] $keyValueArray Associative array of key and values
[265] Fix | Delete
*/
[266] Fix | Delete
public static function withQueryValues(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri, array $keyValueArray) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[267] Fix | Delete
{
[268] Fix | Delete
$result = self::getFilteredQueryString($uri, \array_keys($keyValueArray));
[269] Fix | Delete
foreach ($keyValueArray as $key => $value) {
[270] Fix | Delete
$result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null);
[271] Fix | Delete
}
[272] Fix | Delete
return $uri->withQuery(\implode('&', $result));
[273] Fix | Delete
}
[274] Fix | Delete
/**
[275] Fix | Delete
* Creates a URI from a hash of `parse_url` components.
[276] Fix | Delete
*
[277] Fix | Delete
* @see https://www.php.net/manual/en/function.parse-url.php
[278] Fix | Delete
*
[279] Fix | Delete
* @throws MalformedUriException If the components do not form a valid URI.
[280] Fix | Delete
*/
[281] Fix | Delete
public static function fromParts(array $parts) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[282] Fix | Delete
{
[283] Fix | Delete
$uri = new self();
[284] Fix | Delete
$uri->applyParts($parts);
[285] Fix | Delete
$uri->validateState();
[286] Fix | Delete
return $uri;
[287] Fix | Delete
}
[288] Fix | Delete
public function getScheme() : string
[289] Fix | Delete
{
[290] Fix | Delete
return $this->scheme;
[291] Fix | Delete
}
[292] Fix | Delete
public function getAuthority() : string
[293] Fix | Delete
{
[294] Fix | Delete
$authority = $this->host;
[295] Fix | Delete
if ($this->userInfo !== '') {
[296] Fix | Delete
$authority = $this->userInfo . '@' . $authority;
[297] Fix | Delete
}
[298] Fix | Delete
if ($this->port !== null) {
[299] Fix | Delete
$authority .= ':' . $this->port;
[300] Fix | Delete
}
[301] Fix | Delete
return $authority;
[302] Fix | Delete
}
[303] Fix | Delete
public function getUserInfo() : string
[304] Fix | Delete
{
[305] Fix | Delete
return $this->userInfo;
[306] Fix | Delete
}
[307] Fix | Delete
public function getHost() : string
[308] Fix | Delete
{
[309] Fix | Delete
return $this->host;
[310] Fix | Delete
}
[311] Fix | Delete
public function getPort() : ?int
[312] Fix | Delete
{
[313] Fix | Delete
return $this->port;
[314] Fix | Delete
}
[315] Fix | Delete
public function getPath() : string
[316] Fix | Delete
{
[317] Fix | Delete
return $this->path;
[318] Fix | Delete
}
[319] Fix | Delete
public function getQuery() : string
[320] Fix | Delete
{
[321] Fix | Delete
return $this->query;
[322] Fix | Delete
}
[323] Fix | Delete
public function getFragment() : string
[324] Fix | Delete
{
[325] Fix | Delete
return $this->fragment;
[326] Fix | Delete
}
[327] Fix | Delete
public function withScheme($scheme) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[328] Fix | Delete
{
[329] Fix | Delete
$scheme = $this->filterScheme($scheme);
[330] Fix | Delete
if ($this->scheme === $scheme) {
[331] Fix | Delete
return $this;
[332] Fix | Delete
}
[333] Fix | Delete
$new = clone $this;
[334] Fix | Delete
$new->scheme = $scheme;
[335] Fix | Delete
$new->composedComponents = null;
[336] Fix | Delete
$new->removeDefaultPort();
[337] Fix | Delete
$new->validateState();
[338] Fix | Delete
return $new;
[339] Fix | Delete
}
[340] Fix | Delete
public function withUserInfo($user, $password = null) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[341] Fix | Delete
{
[342] Fix | Delete
$info = $this->filterUserInfoComponent($user);
[343] Fix | Delete
if ($password !== null) {
[344] Fix | Delete
$info .= ':' . $this->filterUserInfoComponent($password);
[345] Fix | Delete
}
[346] Fix | Delete
if ($this->userInfo === $info) {
[347] Fix | Delete
return $this;
[348] Fix | Delete
}
[349] Fix | Delete
$new = clone $this;
[350] Fix | Delete
$new->userInfo = $info;
[351] Fix | Delete
$new->composedComponents = null;
[352] Fix | Delete
$new->validateState();
[353] Fix | Delete
return $new;
[354] Fix | Delete
}
[355] Fix | Delete
public function withHost($host) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[356] Fix | Delete
{
[357] Fix | Delete
$host = $this->filterHost($host);
[358] Fix | Delete
if ($this->host === $host) {
[359] Fix | Delete
return $this;
[360] Fix | Delete
}
[361] Fix | Delete
$new = clone $this;
[362] Fix | Delete
$new->host = $host;
[363] Fix | Delete
$new->composedComponents = null;
[364] Fix | Delete
$new->validateState();
[365] Fix | Delete
return $new;
[366] Fix | Delete
}
[367] Fix | Delete
public function withPort($port) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[368] Fix | Delete
{
[369] Fix | Delete
$port = $this->filterPort($port);
[370] Fix | Delete
if ($this->port === $port) {
[371] Fix | Delete
return $this;
[372] Fix | Delete
}
[373] Fix | Delete
$new = clone $this;
[374] Fix | Delete
$new->port = $port;
[375] Fix | Delete
$new->composedComponents = null;
[376] Fix | Delete
$new->removeDefaultPort();
[377] Fix | Delete
$new->validateState();
[378] Fix | Delete
return $new;
[379] Fix | Delete
}
[380] Fix | Delete
public function withPath($path) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[381] Fix | Delete
{
[382] Fix | Delete
$path = $this->filterPath($path);
[383] Fix | Delete
if ($this->path === $path) {
[384] Fix | Delete
return $this;
[385] Fix | Delete
}
[386] Fix | Delete
$new = clone $this;
[387] Fix | Delete
$new->path = $path;
[388] Fix | Delete
$new->composedComponents = null;
[389] Fix | Delete
$new->validateState();
[390] Fix | Delete
return $new;
[391] Fix | Delete
}
[392] Fix | Delete
public function withQuery($query) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[393] Fix | Delete
{
[394] Fix | Delete
$query = $this->filterQueryAndFragment($query);
[395] Fix | Delete
if ($this->query === $query) {
[396] Fix | Delete
return $this;
[397] Fix | Delete
}
[398] Fix | Delete
$new = clone $this;
[399] Fix | Delete
$new->query = $query;
[400] Fix | Delete
$new->composedComponents = null;
[401] Fix | Delete
return $new;
[402] Fix | Delete
}
[403] Fix | Delete
public function withFragment($fragment) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
[404] Fix | Delete
{
[405] Fix | Delete
$fragment = $this->filterQueryAndFragment($fragment);
[406] Fix | Delete
if ($this->fragment === $fragment) {
[407] Fix | Delete
return $this;
[408] Fix | Delete
}
[409] Fix | Delete
$new = clone $this;
[410] Fix | Delete
$new->fragment = $fragment;
[411] Fix | Delete
$new->composedComponents = null;
[412] Fix | Delete
return $new;
[413] Fix | Delete
}
[414] Fix | Delete
public function jsonSerialize() : string
[415] Fix | Delete
{
[416] Fix | Delete
return $this->__toString();
[417] Fix | Delete
}
[418] Fix | Delete
/**
[419] Fix | Delete
* Apply parse_url parts to a URI.
[420] Fix | Delete
*
[421] Fix | Delete
* @param array $parts Array of parse_url parts to apply.
[422] Fix | Delete
*/
[423] Fix | Delete
private function applyParts(array $parts) : void
[424] Fix | Delete
{
[425] Fix | Delete
$this->scheme = isset($parts['scheme']) ? $this->filterScheme($parts['scheme']) : '';
[426] Fix | Delete
$this->userInfo = isset($parts['user']) ? $this->filterUserInfoComponent($parts['user']) : '';
[427] Fix | Delete
$this->host = isset($parts['host']) ? $this->filterHost($parts['host']) : '';
[428] Fix | Delete
$this->port = isset($parts['port']) ? $this->filterPort($parts['port']) : null;
[429] Fix | Delete
$this->path = isset($parts['path']) ? $this->filterPath($parts['path']) : '';
[430] Fix | Delete
$this->query = isset($parts['query']) ? $this->filterQueryAndFragment($parts['query']) : '';
[431] Fix | Delete
$this->fragment = isset($parts['fragment']) ? $this->filterQueryAndFragment($parts['fragment']) : '';
[432] Fix | Delete
if (isset($parts['pass'])) {
[433] Fix | Delete
$this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']);
[434] Fix | Delete
}
[435] Fix | Delete
$this->removeDefaultPort();
[436] Fix | Delete
}
[437] Fix | Delete
/**
[438] Fix | Delete
* @param mixed $scheme
[439] Fix | Delete
*
[440] Fix | Delete
* @throws \InvalidArgumentException If the scheme is invalid.
[441] Fix | Delete
*/
[442] Fix | Delete
private function filterScheme($scheme) : string
[443] Fix | Delete
{
[444] Fix | Delete
if (!\is_string($scheme)) {
[445] Fix | Delete
throw new \InvalidArgumentException('Scheme must be a string');
[446] Fix | Delete
}
[447] Fix | Delete
return \strtr($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
[448] Fix | Delete
}
[449] Fix | Delete
/**
[450] Fix | Delete
* @param mixed $component
[451] Fix | Delete
*
[452] Fix | Delete
* @throws \InvalidArgumentException If the user info is invalid.
[453] Fix | Delete
*/
[454] Fix | Delete
private function filterUserInfoComponent($component) : string
[455] Fix | Delete
{
[456] Fix | Delete
if (!\is_string($component)) {
[457] Fix | Delete
throw new \InvalidArgumentException('User info must be a string');
[458] Fix | Delete
}
[459] Fix | Delete
return \preg_replace_callback('/(?:[^%' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . ']+|%(?![A-Fa-f0-9]{2}))/', [$this, 'rawurlencodeMatchZero'], $component);
[460] Fix | Delete
}
[461] Fix | Delete
/**
[462] Fix | Delete
* @param mixed $host
[463] Fix | Delete
*
[464] Fix | Delete
* @throws \InvalidArgumentException If the host is invalid.
[465] Fix | Delete
*/
[466] Fix | Delete
private function filterHost($host) : string
[467] Fix | Delete
{
[468] Fix | Delete
if (!\is_string($host)) {
[469] Fix | Delete
throw new \InvalidArgumentException('Host must be a string');
[470] Fix | Delete
}
[471] Fix | Delete
return \strtr($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
[472] Fix | Delete
}
[473] Fix | Delete
/**
[474] Fix | Delete
* @param mixed $port
[475] Fix | Delete
*
[476] Fix | Delete
* @throws \InvalidArgumentException If the port is invalid.
[477] Fix | Delete
*/
[478] Fix | Delete
private function filterPort($port) : ?int
[479] Fix | Delete
{
[480] Fix | Delete
if ($port === null) {
[481] Fix | Delete
return null;
[482] Fix | Delete
}
[483] Fix | Delete
$port = (int) $port;
[484] Fix | Delete
if (0 > $port || 0xffff < $port) {
[485] Fix | Delete
throw new \InvalidArgumentException(\sprintf('Invalid port: %d. Must be between 0 and 65535', $port));
[486] Fix | Delete
}
[487] Fix | Delete
return $port;
[488] Fix | Delete
}
[489] Fix | Delete
/**
[490] Fix | Delete
* @param (string|int)[] $keys
[491] Fix | Delete
*
[492] Fix | Delete
* @return string[]
[493] Fix | Delete
*/
[494] Fix | Delete
private static function getFilteredQueryString(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri, array $keys) : array
[495] Fix | Delete
{
[496] Fix | Delete
$current = $uri->getQuery();
[497] Fix | Delete
if ($current === '') {
[498] Fix | Delete
return [];
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function