Merged in feature/314-dev-dev01 (pull request #24)
auto-patch 314-dev-dev01-2024-01-25T04_09_02 * auto-patch 314-dev-dev01-2024-01-25T04_09_02
This commit is contained in:
@@ -192,7 +192,7 @@ class CookieJar implements \YoastSEO_Vendor\GuzzleHttp\Cookie\CookieJarInterface
|
||||
/**
|
||||
* Computes cookie path following RFC 6265 section 5.1.4
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc6265#section-5.1.4
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.4
|
||||
*/
|
||||
private function getCookiePathFromRequest(\YoastSEO_Vendor\Psr\Http\Message\RequestInterface $request) : string
|
||||
{
|
||||
|
||||
@@ -354,7 +354,7 @@ class SetCookie
|
||||
return \true;
|
||||
}
|
||||
// Remove the leading '.' as per spec in RFC 6265.
|
||||
// https://tools.ietf.org/html/rfc6265#section-5.2.3
|
||||
// https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.3
|
||||
$cookieDomain = \ltrim(\strtolower($cookieDomain), '.');
|
||||
$domain = \strtolower($domain);
|
||||
// Domain not set or exact match.
|
||||
@@ -362,7 +362,7 @@ class SetCookie
|
||||
return \true;
|
||||
}
|
||||
// Matching the subdomain according to RFC 6265.
|
||||
// https://tools.ietf.org/html/rfc6265#section-5.1.3
|
||||
// https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.3
|
||||
if (\filter_var($domain, \FILTER_VALIDATE_IP)) {
|
||||
return \false;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ class CurlFactory implements \YoastSEO_Vendor\GuzzleHttp\Handler\CurlFactoryInte
|
||||
}
|
||||
$method = $easy->request->getMethod();
|
||||
if ($method === 'PUT' || $method === 'POST') {
|
||||
// See https://tools.ietf.org/html/rfc7230#section-3.3.2
|
||||
// See https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2
|
||||
if (!$easy->request->hasHeader('Content-Length')) {
|
||||
$conf[\CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ namespace YoastSEO_Vendor\GuzzleHttp;
|
||||
/**
|
||||
* This class contains a list of built-in Guzzle request options.
|
||||
*
|
||||
* More documentation for each option can be found at http://guzzlephp.org/.
|
||||
*
|
||||
* @see http://docs.guzzlephp.org/en/v6/request-options.html
|
||||
* @see https://docs.guzzlephp.org/en/latest/request-options.html
|
||||
*/
|
||||
final class RequestOptions
|
||||
{
|
||||
|
||||
@@ -155,14 +155,13 @@ No system CA bundle could be found in any of the the common system locations.
|
||||
PHP versions earlier than 5.6 are not properly configured to use the system's
|
||||
CA bundle by default. In order to verify peer certificates, you will need to
|
||||
supply the path on disk to a certificate bundle to the 'verify' request
|
||||
option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not
|
||||
need a specific certificate bundle, then Mozilla provides a commonly used CA
|
||||
bundle which can be downloaded here (provided by the maintainer of cURL):
|
||||
https://curl.haxx.se/ca/cacert.pem. Once
|
||||
you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP
|
||||
ini setting to point to the path to the file, allowing you to omit the 'verify'
|
||||
request option. See https://curl.haxx.se/docs/sslcerts.html for more
|
||||
information.
|
||||
option: https://docs.guzzlephp.org/en/latest/request-options.html#verify. If
|
||||
you do not need a specific certificate bundle, then Mozilla provides a commonly
|
||||
used CA bundle which can be downloaded here (provided by the maintainer of
|
||||
cURL): https://curl.haxx.se/ca/cacert.pem. Once you have a CA bundle available
|
||||
on disk, you can set the 'openssl.cafile' PHP ini setting to point to the path
|
||||
to the file, allowing you to omit the 'verify' request option. See
|
||||
https://curl.haxx.se/docs/sslcerts.html for more information.
|
||||
EOT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,9 +18,7 @@ final class Each
|
||||
* index, and the aggregate promise. The callback can invoke any necessary
|
||||
* side effects and choose to resolve or reject the aggregate if needed.
|
||||
*
|
||||
* @param mixed $iterable Iterator or array to iterate over.
|
||||
* @param callable $onFulfilled
|
||||
* @param callable $onRejected
|
||||
* @param mixed $iterable Iterator or array to iterate over.
|
||||
*/
|
||||
public static function of($iterable, callable $onFulfilled = null, callable $onRejected = null) : \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
@@ -36,8 +34,6 @@ final class Each
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
* @param callable $onRejected
|
||||
*/
|
||||
public static function ofLimit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null) : \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
@@ -50,7 +46,6 @@ final class Each
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
*/
|
||||
public static function ofLimitAll($iterable, $concurrency, callable $onFulfilled = null) : \YoastSEO_Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
|
||||
@@ -113,7 +113,7 @@ class EachPromise implements \YoastSEO_Vendor\GuzzleHttp\Promise\PromisorInterfa
|
||||
return;
|
||||
}
|
||||
// Add only up to N pending promises.
|
||||
$concurrency = \is_callable($this->concurrency) ? \call_user_func($this->concurrency, \count($this->pending)) : $this->concurrency;
|
||||
$concurrency = \is_callable($this->concurrency) ? ($this->concurrency)(\count($this->pending)) : $this->concurrency;
|
||||
$concurrency = \max($concurrency - \count($this->pending), 0);
|
||||
// Concurrency may be set to 0 to disallow new promises.
|
||||
if (!$concurrency) {
|
||||
@@ -140,12 +140,12 @@ class EachPromise implements \YoastSEO_Vendor\GuzzleHttp\Promise\PromisorInterfa
|
||||
$idx = $this->nextPendingIndex++;
|
||||
$this->pending[$idx] = $promise->then(function ($value) use($idx, $key) : void {
|
||||
if ($this->onFulfilled) {
|
||||
\call_user_func($this->onFulfilled, $value, $key, $this->aggregate);
|
||||
($this->onFulfilled)($value, $key, $this->aggregate);
|
||||
}
|
||||
$this->step($idx);
|
||||
}, function ($reason) use($idx, $key) : void {
|
||||
if ($this->onRejected) {
|
||||
\call_user_func($this->onRejected, $reason, $key, $this->aggregate);
|
||||
($this->onRejected)($reason, $key, $this->aggregate);
|
||||
}
|
||||
$this->step($idx);
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@ class RejectionException extends \RuntimeException
|
||||
* @param mixed $reason Rejection reason.
|
||||
* @param string|null $description Optional description.
|
||||
*/
|
||||
public function __construct($reason, ?string $description = null)
|
||||
public function __construct($reason, string $description = null)
|
||||
{
|
||||
$this->reason = $reason;
|
||||
$message = 'The promise was rejected';
|
||||
|
||||
@@ -42,7 +42,7 @@ final class FnStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterfac
|
||||
public function __destruct()
|
||||
{
|
||||
if (isset($this->_fn_close)) {
|
||||
\call_user_func($this->_fn_close);
|
||||
($this->_fn_close)();
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -77,7 +77,8 @@ final class FnStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterfac
|
||||
public function __toString() : string
|
||||
{
|
||||
try {
|
||||
return \call_user_func($this->_fn___toString);
|
||||
/** @var string */
|
||||
return ($this->_fn___toString)();
|
||||
} catch (\Throwable $e) {
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw $e;
|
||||
@@ -88,61 +89,61 @@ final class FnStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterfac
|
||||
}
|
||||
public function close() : void
|
||||
{
|
||||
\call_user_func($this->_fn_close);
|
||||
($this->_fn_close)();
|
||||
}
|
||||
public function detach()
|
||||
{
|
||||
return \call_user_func($this->_fn_detach);
|
||||
return ($this->_fn_detach)();
|
||||
}
|
||||
public function getSize() : ?int
|
||||
{
|
||||
return \call_user_func($this->_fn_getSize);
|
||||
return ($this->_fn_getSize)();
|
||||
}
|
||||
public function tell() : int
|
||||
{
|
||||
return \call_user_func($this->_fn_tell);
|
||||
return ($this->_fn_tell)();
|
||||
}
|
||||
public function eof() : bool
|
||||
{
|
||||
return \call_user_func($this->_fn_eof);
|
||||
return ($this->_fn_eof)();
|
||||
}
|
||||
public function isSeekable() : bool
|
||||
{
|
||||
return \call_user_func($this->_fn_isSeekable);
|
||||
return ($this->_fn_isSeekable)();
|
||||
}
|
||||
public function rewind() : void
|
||||
{
|
||||
\call_user_func($this->_fn_rewind);
|
||||
($this->_fn_rewind)();
|
||||
}
|
||||
public function seek($offset, $whence = \SEEK_SET) : void
|
||||
{
|
||||
\call_user_func($this->_fn_seek, $offset, $whence);
|
||||
($this->_fn_seek)($offset, $whence);
|
||||
}
|
||||
public function isWritable() : bool
|
||||
{
|
||||
return \call_user_func($this->_fn_isWritable);
|
||||
return ($this->_fn_isWritable)();
|
||||
}
|
||||
public function write($string) : int
|
||||
{
|
||||
return \call_user_func($this->_fn_write, $string);
|
||||
return ($this->_fn_write)($string);
|
||||
}
|
||||
public function isReadable() : bool
|
||||
{
|
||||
return \call_user_func($this->_fn_isReadable);
|
||||
return ($this->_fn_isReadable)();
|
||||
}
|
||||
public function read($length) : string
|
||||
{
|
||||
return \call_user_func($this->_fn_read, $length);
|
||||
return ($this->_fn_read)($length);
|
||||
}
|
||||
public function getContents() : string
|
||||
{
|
||||
return \call_user_func($this->_fn_getContents);
|
||||
return ($this->_fn_getContents)();
|
||||
}
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMetadata($key = null)
|
||||
{
|
||||
return \call_user_func($this->_fn_getMetadata, $key);
|
||||
return ($this->_fn_getMetadata)($key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ final class Header
|
||||
foreach ((array) $header as $value) {
|
||||
foreach (self::splitList($value) as $val) {
|
||||
$part = [];
|
||||
foreach (\preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
|
||||
foreach (\preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) ?: [] as $kvp) {
|
||||
if (\preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
|
||||
$m = $matches[0];
|
||||
if (isset($m[1])) {
|
||||
|
||||
@@ -11,9 +11,9 @@ use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
|
||||
* then appends the zlib.inflate filter. The stream is then converted back
|
||||
* to a Guzzle stream resource to be used as a Guzzle stream.
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc1950
|
||||
* @see http://tools.ietf.org/html/rfc1952
|
||||
* @see http://php.net/manual/en/filters.compression.php
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc1950
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc1952
|
||||
* @see https://www.php.net/manual/en/filters.compression.php
|
||||
*/
|
||||
final class InflateStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
|
||||
{
|
||||
@@ -24,7 +24,7 @@ final class InflateStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInt
|
||||
{
|
||||
$resource = \YoastSEO_Vendor\GuzzleHttp\Psr7\StreamWrapper::getResource($stream);
|
||||
// Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data
|
||||
// See http://www.zlib.net/manual.html#Advanced definition of inflateInit2
|
||||
// See https://www.zlib.net/manual.html#Advanced definition of inflateInit2
|
||||
// "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection"
|
||||
// Default window size is 15.
|
||||
\stream_filter_append($resource, 'zlib.inflate', \STREAM_FILTER_READ, ['window' => 15 + 32]);
|
||||
|
||||
@@ -119,7 +119,7 @@ final class Message
|
||||
$count = \preg_match_all(\YoastSEO_Vendor\GuzzleHttp\Psr7\Rfc7230::HEADER_REGEX, $rawHeaders, $headerLines, \PREG_SET_ORDER);
|
||||
// If these aren't the same, then one line didn't match and there's an invalid header.
|
||||
if ($count !== \substr_count($rawHeaders, "\n")) {
|
||||
// Folding is deprecated, see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
||||
// Folding is deprecated, see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4
|
||||
if (\preg_match(\YoastSEO_Vendor\GuzzleHttp\Psr7\Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) {
|
||||
throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding');
|
||||
}
|
||||
@@ -177,9 +177,9 @@ final class Message
|
||||
public static function parseResponse(string $message) : \YoastSEO_Vendor\Psr\Http\Message\ResponseInterface
|
||||
{
|
||||
$data = self::parseMessage($message);
|
||||
// According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
|
||||
// between status-code and reason-phrase is required. But browsers accept
|
||||
// responses without space and reason as well.
|
||||
// According to https://datatracker.ietf.org/doc/html/rfc7230#section-3.1.2
|
||||
// the space between status-code and reason-phrase is required. But
|
||||
// browsers accept responses without space and reason as well.
|
||||
if (!\preg_match('/^HTTP\\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
|
||||
throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ trait MessageTrait
|
||||
return $new;
|
||||
}
|
||||
/**
|
||||
* @param array<string|int, string|string[]> $headers
|
||||
* @param (string|string[])[] $headers
|
||||
*/
|
||||
private function setHeaders(array $headers) : void
|
||||
{
|
||||
@@ -155,7 +155,7 @@ trait MessageTrait
|
||||
*
|
||||
* @return string[] Trimmed header values
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4
|
||||
*/
|
||||
private function trimAndValidateHeaderValues(array $values) : array
|
||||
{
|
||||
@@ -169,7 +169,7 @@ trait MessageTrait
|
||||
}, \array_values($values));
|
||||
}
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
|
||||
*
|
||||
* @param mixed $header
|
||||
*/
|
||||
@@ -183,7 +183,7 @@ trait MessageTrait
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
|
||||
*
|
||||
* field-value = *( field-content / obs-fold )
|
||||
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
||||
|
||||
@@ -43,7 +43,7 @@ final class MultipartStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamI
|
||||
/**
|
||||
* Get the headers needed before transferring the content of a POST file
|
||||
*
|
||||
* @param array<string, string> $headers
|
||||
* @param string[] $headers
|
||||
*/
|
||||
private function getHeaders(array $headers) : string
|
||||
{
|
||||
@@ -88,32 +88,40 @@ final class MultipartStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamI
|
||||
$stream->addStream($body);
|
||||
$stream->addStream(\YoastSEO_Vendor\GuzzleHttp\Psr7\Utils::streamFor("\r\n"));
|
||||
}
|
||||
/**
|
||||
* @param string[] $headers
|
||||
*
|
||||
* @return array{0: StreamInterface, 1: string[]}
|
||||
*/
|
||||
private function createElement(string $name, \YoastSEO_Vendor\Psr\Http\Message\StreamInterface $stream, ?string $filename, array $headers) : array
|
||||
{
|
||||
// Set a default content-disposition header if one was no provided
|
||||
$disposition = $this->getHeader($headers, 'content-disposition');
|
||||
$disposition = self::getHeader($headers, 'content-disposition');
|
||||
if (!$disposition) {
|
||||
$headers['Content-Disposition'] = $filename === '0' || $filename ? \sprintf('form-data; name="%s"; filename="%s"', $name, \basename($filename)) : "form-data; name=\"{$name}\"";
|
||||
}
|
||||
// Set a default content-length header if one was no provided
|
||||
$length = $this->getHeader($headers, 'content-length');
|
||||
$length = self::getHeader($headers, 'content-length');
|
||||
if (!$length) {
|
||||
if ($length = $stream->getSize()) {
|
||||
$headers['Content-Length'] = (string) $length;
|
||||
}
|
||||
}
|
||||
// Set a default Content-Type if one was not supplied
|
||||
$type = $this->getHeader($headers, 'content-type');
|
||||
$type = self::getHeader($headers, 'content-type');
|
||||
if (!$type && ($filename === '0' || $filename)) {
|
||||
$headers['Content-Type'] = \YoastSEO_Vendor\GuzzleHttp\Psr7\MimeType::fromFilename($filename) ?? 'application/octet-stream';
|
||||
}
|
||||
return [$stream, $headers];
|
||||
}
|
||||
private function getHeader(array $headers, string $key)
|
||||
/**
|
||||
* @param string[] $headers
|
||||
*/
|
||||
private static function getHeader(array $headers, string $key) : ?string
|
||||
{
|
||||
$lowercaseHeader = \strtolower($key);
|
||||
foreach ($headers as $k => $v) {
|
||||
if (\strtolower($k) === $lowercaseHeader) {
|
||||
if (\strtolower((string) $k) === $lowercaseHeader) {
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
|
||||
*/
|
||||
final class PumpStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
|
||||
{
|
||||
/** @var callable|null */
|
||||
/** @var callable(int): (string|false|null)|null */
|
||||
private $source;
|
||||
/** @var int|null */
|
||||
private $size;
|
||||
@@ -134,9 +134,9 @@ final class PumpStream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterf
|
||||
}
|
||||
private function pump(int $length) : void
|
||||
{
|
||||
if ($this->source) {
|
||||
if ($this->source !== null) {
|
||||
do {
|
||||
$data = \call_user_func($this->source, $length);
|
||||
$data = ($this->source)($length);
|
||||
if ($data === \false || $data === null) {
|
||||
$this->source = null;
|
||||
return;
|
||||
|
||||
@@ -22,7 +22,7 @@ class Request implements \YoastSEO_Vendor\Psr\Http\Message\RequestInterface
|
||||
/**
|
||||
* @param string $method HTTP method
|
||||
* @param string|UriInterface $uri URI
|
||||
* @param array<string, string|string[]> $headers Request headers
|
||||
* @param (string|string[])[] $headers Request headers
|
||||
* @param string|resource|StreamInterface|null $body Request body
|
||||
* @param string $version Protocol version
|
||||
*/
|
||||
@@ -109,7 +109,7 @@ class Request implements \YoastSEO_Vendor\Psr\Http\Message\RequestInterface
|
||||
$this->headerNames['host'] = 'Host';
|
||||
}
|
||||
// Ensure Host is the first header.
|
||||
// See: http://tools.ietf.org/html/rfc7230#section-5.4
|
||||
// See: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
|
||||
$this->headers = [$header => [$host]] + $this->headers;
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -19,7 +19,7 @@ class Response implements \YoastSEO_Vendor\Psr\Http\Message\ResponseInterface
|
||||
private $statusCode;
|
||||
/**
|
||||
* @param int $status Status code
|
||||
* @param array<string, string|string[]> $headers Response headers
|
||||
* @param (string|string[])[] $headers Response headers
|
||||
* @param string|resource|StreamInterface|null $body Response body
|
||||
* @param string $version Protocol version
|
||||
* @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
|
||||
|
||||
@@ -51,7 +51,7 @@ class ServerRequest extends \YoastSEO_Vendor\GuzzleHttp\Psr7\Request implements
|
||||
/**
|
||||
* @param string $method HTTP method
|
||||
* @param string|UriInterface $uri URI
|
||||
* @param array<string, string|string[]> $headers Request headers
|
||||
* @param (string|string[])[] $headers Request headers
|
||||
* @param string|resource|StreamInterface|null $body Request body
|
||||
* @param string $version Protocol version
|
||||
* @param array $serverParams Typically the $_SERVER superglobal
|
||||
|
||||
@@ -10,8 +10,8 @@ use YoastSEO_Vendor\Psr\Http\Message\StreamInterface;
|
||||
class Stream implements \YoastSEO_Vendor\Psr\Http\Message\StreamInterface
|
||||
{
|
||||
/**
|
||||
* @see http://php.net/manual/function.fopen.php
|
||||
* @see http://php.net/manual/en/function.gzopen.php
|
||||
* @see https://www.php.net/manual/en/function.fopen.php
|
||||
* @see https://www.php.net/manual/en/function.gzopen.php
|
||||
*/
|
||||
private const READABLE_MODES = '/r|a\\+|ab\\+|w\\+|wb\\+|x\\+|xb\\+|c\\+|cb\\+/';
|
||||
private const WRITABLE_MODES = '/a|w|r\\+|rb\\+|rw|x|c/';
|
||||
|
||||
@@ -60,7 +60,7 @@ trait StreamDecoratorTrait
|
||||
{
|
||||
/** @var callable $callable */
|
||||
$callable = [$this->stream, $method];
|
||||
$result = \call_user_func_array($callable, $args);
|
||||
$result = $callable(...$args);
|
||||
// Always return the wrapped object if the result is a return $this
|
||||
return $result === $this->stream ? $this : $result;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,21 @@ final class StreamWrapper
|
||||
return $resource ?? \false;
|
||||
}
|
||||
/**
|
||||
* @return array<int|string, int>
|
||||
* @return array{
|
||||
* dev: int,
|
||||
* ino: int,
|
||||
* mode: int,
|
||||
* nlink: int,
|
||||
* uid: int,
|
||||
* gid: int,
|
||||
* rdev: int,
|
||||
* size: int,
|
||||
* atime: int,
|
||||
* mtime: int,
|
||||
* ctime: int,
|
||||
* blksize: int,
|
||||
* blocks: int
|
||||
* }
|
||||
*/
|
||||
public function stream_stat() : array
|
||||
{
|
||||
@@ -105,7 +119,21 @@ final class StreamWrapper
|
||||
return ['dev' => 0, 'ino' => 0, 'mode' => $modeMap[$this->mode], 'nlink' => 0, 'uid' => 0, 'gid' => 0, 'rdev' => 0, 'size' => $this->stream->getSize() ?: 0, 'atime' => 0, 'mtime' => 0, 'ctime' => 0, 'blksize' => 0, 'blocks' => 0];
|
||||
}
|
||||
/**
|
||||
* @return array<int|string, int>
|
||||
* @return array{
|
||||
* dev: int,
|
||||
* ino: int,
|
||||
* mode: int,
|
||||
* nlink: int,
|
||||
* uid: int,
|
||||
* gid: int,
|
||||
* rdev: int,
|
||||
* size: int,
|
||||
* atime: int,
|
||||
* mtime: int,
|
||||
* ctime: int,
|
||||
* blksize: int,
|
||||
* blocks: int
|
||||
* }
|
||||
*/
|
||||
public function url_stat(string $path, int $flags) : array
|
||||
{
|
||||
|
||||
@@ -80,7 +80,7 @@ class UploadedFile implements \YoastSEO_Vendor\Psr\Http\Message\UploadedFileInte
|
||||
}
|
||||
$this->error = $error;
|
||||
}
|
||||
private function isStringNotEmpty($param) : bool
|
||||
private static function isStringNotEmpty($param) : bool
|
||||
{
|
||||
return \is_string($param) && \false === empty($param);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ class UploadedFile implements \YoastSEO_Vendor\Psr\Http\Message\UploadedFileInte
|
||||
public function moveTo($targetPath) : void
|
||||
{
|
||||
$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');
|
||||
}
|
||||
if ($this->file) {
|
||||
|
||||
@@ -25,13 +25,13 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
/**
|
||||
* Unreserved characters for use in a regex.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-2.3
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
|
||||
*/
|
||||
private const CHAR_UNRESERVED = 'a-zA-Z0-9_\\-\\.~';
|
||||
/**
|
||||
* Sub-delims for use in a regex.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-2.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
|
||||
*/
|
||||
private const CHAR_SUB_DELIMS = '!\\$&\'\\(\\)\\*\\+,;=';
|
||||
private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26'];
|
||||
@@ -118,7 +118,7 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
* `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
|
||||
* that format).
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-5.3
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.3
|
||||
*/
|
||||
public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment) : string
|
||||
{
|
||||
@@ -165,7 +165,7 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
* @see Uri::isNetworkPathReference
|
||||
* @see Uri::isAbsolutePathReference
|
||||
* @see Uri::isRelativePathReference
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-4
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4
|
||||
*/
|
||||
public static function isAbsolute(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -176,7 +176,7 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
*
|
||||
* A relative reference that begins with two slash characters is termed an network-path reference.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-4.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
||||
*/
|
||||
public static function isNetworkPathReference(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -187,7 +187,7 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
*
|
||||
* A relative reference that begins with a single slash character is termed an absolute-path reference.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-4.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
||||
*/
|
||||
public static function isAbsolutePathReference(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -198,7 +198,7 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
*
|
||||
* A relative reference that does not begin with a slash character is termed a relative-path reference.
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-4.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
||||
*/
|
||||
public static function isRelativePathReference(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -214,7 +214,7 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
* @param UriInterface $uri The URI to check
|
||||
* @param UriInterface|null $base An optional base URI to compare against
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-4.4
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.4
|
||||
*/
|
||||
public static function isSameDocumentReference(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri, \YoastSEO_Vendor\Psr\Http\Message\UriInterface $base = null) : bool
|
||||
{
|
||||
@@ -262,8 +262,8 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
*
|
||||
* It has the same behavior as withQueryValue() but for an associative array of key => value.
|
||||
*
|
||||
* @param UriInterface $uri URI to use as a base.
|
||||
* @param array<string, string|null> $keyValueArray Associative array of key and values
|
||||
* @param UriInterface $uri URI to use as a base.
|
||||
* @param (string|null)[] $keyValueArray Associative array of key and values
|
||||
*/
|
||||
public static function withQueryValues(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri, array $keyValueArray) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
@@ -276,7 +276,7 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
/**
|
||||
* Creates a URI from a hash of `parse_url` components.
|
||||
*
|
||||
* @see http://php.net/manual/en/function.parse-url.php
|
||||
* @see https://www.php.net/manual/en/function.parse-url.php
|
||||
*
|
||||
* @throws MalformedUriException If the components do not form a valid URI.
|
||||
*/
|
||||
@@ -489,7 +489,7 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
return $port;
|
||||
}
|
||||
/**
|
||||
* @param string[] $keys
|
||||
* @param (string|int)[] $keys
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
@@ -499,7 +499,9 @@ class Uri implements \YoastSEO_Vendor\Psr\Http\Message\UriInterface, \JsonSerial
|
||||
if ($current === '') {
|
||||
return [];
|
||||
}
|
||||
$decodedKeys = \array_map('rawurldecode', $keys);
|
||||
$decodedKeys = \array_map(function ($k) : string {
|
||||
return \rawurldecode((string) $k);
|
||||
}, $keys);
|
||||
return \array_filter(\explode('&', $current), function ($part) use($decodedKeys) {
|
||||
return !\in_array(\rawurldecode(\explode('=', $part)[0]), $decodedKeys, \true);
|
||||
});
|
||||
|
||||
@@ -9,7 +9,7 @@ use YoastSEO_Vendor\Psr\Http\Message\UriInterface;
|
||||
*
|
||||
* @author Tobias Schultze
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-6
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6
|
||||
*/
|
||||
final class UriNormalizer
|
||||
{
|
||||
@@ -102,7 +102,7 @@ final class UriNormalizer
|
||||
* @param UriInterface $uri The URI to normalize
|
||||
* @param int $flags A bitmask of normalizations to apply, see constants
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-6.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2
|
||||
*/
|
||||
public static function normalize(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
@@ -146,7 +146,7 @@ final class UriNormalizer
|
||||
* @param UriInterface $uri2 An URI to compare
|
||||
* @param int $normalizations A bitmask of normalizations to apply, see constants
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-6.1
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.1
|
||||
*/
|
||||
public static function isEquivalent(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri1, \YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS) : bool
|
||||
{
|
||||
@@ -155,7 +155,7 @@ final class UriNormalizer
|
||||
private static function capitalizePercentEncoding(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
$regex = '/(?:%[A-Fa-f0-9]{2})++/';
|
||||
$callback = function (array $match) {
|
||||
$callback = function (array $match) : string {
|
||||
return \strtoupper($match[0]);
|
||||
};
|
||||
return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
|
||||
@@ -163,7 +163,7 @@ final class UriNormalizer
|
||||
private static function decodeUnreservedCharacters(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $uri) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
$regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
|
||||
$callback = function (array $match) {
|
||||
$callback = function (array $match) : string {
|
||||
return \rawurldecode($match[0]);
|
||||
};
|
||||
return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
|
||||
|
||||
@@ -9,14 +9,14 @@ use YoastSEO_Vendor\Psr\Http\Message\UriInterface;
|
||||
*
|
||||
* @author Tobias Schultze
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-5
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5
|
||||
*/
|
||||
final class UriResolver
|
||||
{
|
||||
/**
|
||||
* Removes dot segments from a path and returns the new path.
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc3986#section-5.2.4
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
|
||||
*/
|
||||
public static function removeDotSegments(string $path) : string
|
||||
{
|
||||
@@ -46,7 +46,7 @@ final class UriResolver
|
||||
/**
|
||||
* Converts the relative URI into a new URI that is resolved against the base URI.
|
||||
*
|
||||
* @see http://tools.ietf.org/html/rfc3986#section-5.2
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2
|
||||
*/
|
||||
public static function resolve(\YoastSEO_Vendor\Psr\Http\Message\UriInterface $base, \YoastSEO_Vendor\Psr\Http\Message\UriInterface $rel) : \YoastSEO_Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
|
||||
@@ -12,16 +12,16 @@ final class Utils
|
||||
/**
|
||||
* Remove the items given by the keys, case insensitively from the data.
|
||||
*
|
||||
* @param string[] $keys
|
||||
* @param (string|int)[] $keys
|
||||
*/
|
||||
public static function caselessRemove(array $keys, array $data) : array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($keys as &$key) {
|
||||
$key = \strtolower($key);
|
||||
$key = \strtolower((string) $key);
|
||||
}
|
||||
foreach ($data as $k => $v) {
|
||||
if (!\is_string($k) || !\in_array(\strtolower($k), $keys)) {
|
||||
if (!\in_array(\strtolower((string) $k), $keys)) {
|
||||
$result[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user