plugin updates
This commit is contained in:
@@ -109,7 +109,7 @@ class Client implements \WPMailSMTP\Vendor\GuzzleHttp\ClientInterface, \WPMailSM
|
||||
/**
|
||||
* The HttpClient PSR (PSR-18) specify this method.
|
||||
*
|
||||
* @inheritDoc
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function sendRequest(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request) : \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface
|
||||
{
|
||||
@@ -178,7 +178,7 @@ class Client implements \WPMailSMTP\Vendor\GuzzleHttp\ClientInterface, \WPMailSM
|
||||
*
|
||||
* @deprecated Client::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
||||
*/
|
||||
public function getConfig(?string $option = null)
|
||||
public function getConfig(string $option = null)
|
||||
{
|
||||
return $option === null ? $this->config : $this->config[$option] ?? null;
|
||||
}
|
||||
@@ -367,6 +367,9 @@ class Client implements \WPMailSMTP\Vendor\GuzzleHttp\ClientInterface, \WPMailSM
|
||||
throw new \WPMailSMTP\Vendor\GuzzleHttp\Exception\InvalidArgumentException('sink must not be a boolean');
|
||||
}
|
||||
}
|
||||
if (isset($options['version'])) {
|
||||
$modify['version'] = $options['version'];
|
||||
}
|
||||
$request = \WPMailSMTP\Vendor\GuzzleHttp\Psr7\Utils::modifyRequest($request, $modify);
|
||||
if ($request->getBody() instanceof \WPMailSMTP\Vendor\GuzzleHttp\Psr7\MultipartStream) {
|
||||
// Use a multipart/form-data POST if a Content-Type is not set.
|
||||
|
||||
@@ -74,5 +74,5 @@ interface ClientInterface
|
||||
*
|
||||
* @deprecated ClientInterface::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
||||
*/
|
||||
public function getConfig(?string $option = null);
|
||||
public function getConfig(string $option = null);
|
||||
}
|
||||
|
||||
@@ -80,19 +80,13 @@ class CookieJar implements \WPMailSMTP\Vendor\GuzzleHttp\Cookie\CookieJarInterfa
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray() : array
|
||||
{
|
||||
return \array_map(static function (\WPMailSMTP\Vendor\GuzzleHttp\Cookie\SetCookie $cookie) : array {
|
||||
return $cookie->toArray();
|
||||
}, $this->getIterator()->getArrayCopy());
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function clear(?string $domain = null, ?string $path = null, ?string $name = null) : void
|
||||
public function clear(string $domain = null, string $path = null, string $name = null) : void
|
||||
{
|
||||
if (!$domain) {
|
||||
$this->cookies = [];
|
||||
@@ -111,18 +105,12 @@ class CookieJar implements \WPMailSMTP\Vendor\GuzzleHttp\Cookie\CookieJarInterfa
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function clearSessionCookies() : void
|
||||
{
|
||||
$this->cookies = \array_filter($this->cookies, static function (\WPMailSMTP\Vendor\GuzzleHttp\Cookie\SetCookie $cookie) : bool {
|
||||
return !$cookie->getDiscard() && $cookie->getExpires();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setCookie(\WPMailSMTP\Vendor\GuzzleHttp\Cookie\SetCookie $cookie) : bool
|
||||
{
|
||||
// If the name string is empty (but not 0), ignore the set-cookie
|
||||
@@ -204,7 +192,7 @@ class CookieJar implements \WPMailSMTP\Vendor\GuzzleHttp\Cookie\CookieJarInterfa
|
||||
/**
|
||||
* Computes cookie path following RFC 6265 section 5.1.4
|
||||
*
|
||||
* @link 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(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request) : string
|
||||
{
|
||||
|
||||
@@ -12,7 +12,8 @@ use WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface;
|
||||
* necessary. Subclasses are also responsible for storing and retrieving
|
||||
* cookies from a file, database, etc.
|
||||
*
|
||||
* @link https://docs.python.org/2/library/cookielib.html Inspiration
|
||||
* @see https://docs.python.org/2/library/cookielib.html Inspiration
|
||||
*
|
||||
* @extends \IteratorAggregate<SetCookie>
|
||||
*/
|
||||
interface CookieJarInterface extends \Countable, \IteratorAggregate
|
||||
@@ -57,7 +58,7 @@ interface CookieJarInterface extends \Countable, \IteratorAggregate
|
||||
* @param string|null $path Clears cookies matching a domain and path
|
||||
* @param string|null $name Clears cookies matching a domain, path, and name
|
||||
*/
|
||||
public function clear(?string $domain = null, ?string $path = null, ?string $name = null) : void;
|
||||
public function clear(string $domain = null, string $path = null, string $name = null) : void;
|
||||
/**
|
||||
* Discard all sessions cookies.
|
||||
*
|
||||
|
||||
@@ -65,7 +65,7 @@ class SessionCookieJar extends \WPMailSMTP\Vendor\GuzzleHttp\Cookie\CookieJar
|
||||
$this->setCookie(new \WPMailSMTP\Vendor\GuzzleHttp\Cookie\SetCookie($cookie));
|
||||
}
|
||||
} elseif (\strlen($data)) {
|
||||
throw new \RuntimeException("Invalid cookie data");
|
||||
throw new \RuntimeException('Invalid cookie data');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,13 @@ class SetCookie
|
||||
} else {
|
||||
foreach (\array_keys(self::$defaults) as $search) {
|
||||
if (!\strcasecmp($search, $key)) {
|
||||
$data[$search] = $value;
|
||||
if ($search === 'Max-Age') {
|
||||
if (\is_numeric($value)) {
|
||||
$data[$search] = (int) $value;
|
||||
}
|
||||
} else {
|
||||
$data[$search] = $value;
|
||||
}
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
@@ -56,12 +62,38 @@ class SetCookie
|
||||
*/
|
||||
public function __construct(array $data = [])
|
||||
{
|
||||
/** @var array|null $replaced will be null in case of replace error */
|
||||
$replaced = \array_replace(self::$defaults, $data);
|
||||
if ($replaced === null) {
|
||||
throw new \InvalidArgumentException('Unable to replace the default values for the Cookie.');
|
||||
$this->data = self::$defaults;
|
||||
if (isset($data['Name'])) {
|
||||
$this->setName($data['Name']);
|
||||
}
|
||||
if (isset($data['Value'])) {
|
||||
$this->setValue($data['Value']);
|
||||
}
|
||||
if (isset($data['Domain'])) {
|
||||
$this->setDomain($data['Domain']);
|
||||
}
|
||||
if (isset($data['Path'])) {
|
||||
$this->setPath($data['Path']);
|
||||
}
|
||||
if (isset($data['Max-Age'])) {
|
||||
$this->setMaxAge($data['Max-Age']);
|
||||
}
|
||||
if (isset($data['Expires'])) {
|
||||
$this->setExpires($data['Expires']);
|
||||
}
|
||||
if (isset($data['Secure'])) {
|
||||
$this->setSecure($data['Secure']);
|
||||
}
|
||||
if (isset($data['Discard'])) {
|
||||
$this->setDiscard($data['Discard']);
|
||||
}
|
||||
if (isset($data['HttpOnly'])) {
|
||||
$this->setHttpOnly($data['HttpOnly']);
|
||||
}
|
||||
// Set the remaining values that don't have extra validation logic
|
||||
foreach (\array_diff(\array_keys($data), \array_keys(self::$defaults)) as $key) {
|
||||
$this->data[$key] = $data[$key];
|
||||
}
|
||||
$this->data = $replaced;
|
||||
// Extract the Expires value and turn it into a UNIX timestamp if needed
|
||||
if (!$this->getExpires() && $this->getMaxAge()) {
|
||||
// Calculate the Expires date
|
||||
@@ -322,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.
|
||||
@@ -330,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;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
*/
|
||||
private function getDefaultConf(\WPMailSMTP\Vendor\GuzzleHttp\Handler\EasyHandle $easy) : array
|
||||
{
|
||||
$conf = ['_headers' => $easy->request->getHeaders(), \CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(), \CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), \CURLOPT_RETURNTRANSFER => \false, \CURLOPT_HEADER => \false, \CURLOPT_CONNECTTIMEOUT => 150];
|
||||
$conf = ['_headers' => $easy->request->getHeaders(), \CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(), \CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), \CURLOPT_RETURNTRANSFER => \false, \CURLOPT_HEADER => \false, \CURLOPT_CONNECTTIMEOUT => 300];
|
||||
if (\defined('CURLOPT_PROTOCOLS')) {
|
||||
$conf[\CURLOPT_PROTOCOLS] = \CURLPROTO_HTTP | \CURLPROTO_HTTPS;
|
||||
}
|
||||
@@ -175,7 +175,7 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
}
|
||||
$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';
|
||||
}
|
||||
@@ -334,12 +334,39 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
$scheme = $easy->request->getUri()->getScheme();
|
||||
if (isset($options['proxy'][$scheme])) {
|
||||
$host = $easy->request->getUri()->getHost();
|
||||
if (!isset($options['proxy']['no']) || !\WPMailSMTP\Vendor\GuzzleHttp\Utils::isHostInNoProxy($host, $options['proxy']['no'])) {
|
||||
if (isset($options['proxy']['no']) && \WPMailSMTP\Vendor\GuzzleHttp\Utils::isHostInNoProxy($host, $options['proxy']['no'])) {
|
||||
unset($conf[\CURLOPT_PROXY]);
|
||||
} else {
|
||||
$conf[\CURLOPT_PROXY] = $options['proxy'][$scheme];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($options['crypto_method'])) {
|
||||
if (\STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT === $options['crypto_method']) {
|
||||
if (!\defined('CURL_SSLVERSION_TLSv1_0')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.0 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_0;
|
||||
} elseif (\STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT === $options['crypto_method']) {
|
||||
if (!\defined('CURL_SSLVERSION_TLSv1_1')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.1 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_1;
|
||||
} elseif (\STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT === $options['crypto_method']) {
|
||||
if (!\defined('CURL_SSLVERSION_TLSv1_2')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.2 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_2;
|
||||
} elseif (\defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT === $options['crypto_method']) {
|
||||
if (!\defined('CURL_SSLVERSION_TLSv1_3')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.3 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_3;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided');
|
||||
}
|
||||
}
|
||||
if (isset($options['cert'])) {
|
||||
$cert = $options['cert'];
|
||||
if (\is_array($cert)) {
|
||||
@@ -349,8 +376,8 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
if (!\file_exists($cert)) {
|
||||
throw new \InvalidArgumentException("SSL certificate not found: {$cert}");
|
||||
}
|
||||
# OpenSSL (versions 0.9.3 and later) also support "P12" for PKCS#12-encoded files.
|
||||
# see https://curl.se/libcurl/c/CURLOPT_SSLCERTTYPE.html
|
||||
// OpenSSL (versions 0.9.3 and later) also support "P12" for PKCS#12-encoded files.
|
||||
// see https://curl.se/libcurl/c/CURLOPT_SSLCERTTYPE.html
|
||||
$ext = \pathinfo($cert, \PATHINFO_EXTENSION);
|
||||
if (\preg_match('#^(der|p12)$#i', $ext)) {
|
||||
$conf[\CURLOPT_SSLCERTTYPE] = \strtoupper($ext);
|
||||
@@ -416,7 +443,7 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
$ctx['error'] = 'The cURL request was retried 3 times ' . 'and did not succeed. The most likely reason for the failure ' . 'is that cURL was unable to rewind the body of the request ' . 'and subsequent retries resulted in the same error. Turn on ' . 'the debug option to see what went wrong. See ' . 'https://bugs.php.net/bug.php?id=47204 for more information.';
|
||||
return self::createRejection($easy, $ctx);
|
||||
} else {
|
||||
$easy->options['_curl_retries']++;
|
||||
++$easy->options['_curl_retries'];
|
||||
}
|
||||
return $handler($easy->request, $easy->options);
|
||||
}
|
||||
@@ -459,4 +486,11 @@ class CurlFactory implements \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlFactoryIn
|
||||
return \strlen($h);
|
||||
};
|
||||
}
|
||||
public function __destruct()
|
||||
{
|
||||
foreach ($this->handles as $id => $handle) {
|
||||
\curl_close($handle);
|
||||
unset($this->handles[$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@ use WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface;
|
||||
* associative array of curl option constants mapping to values in the
|
||||
* **curl** key of the provided request options.
|
||||
*
|
||||
* @property resource|\CurlMultiHandle $_mh Internal use only. Lazy loaded multi-handle.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class CurlMultiHandler
|
||||
@@ -48,6 +46,8 @@ class CurlMultiHandler
|
||||
* @var array<mixed> An associative array of CURLMOPT_* options and corresponding values for curl_multi_setopt()
|
||||
*/
|
||||
private $options = [];
|
||||
/** @var resource|\CurlMultiHandle */
|
||||
private $_mh;
|
||||
/**
|
||||
* This handler accepts the following options:
|
||||
*
|
||||
@@ -69,6 +69,9 @@ class CurlMultiHandler
|
||||
$this->selectTimeout = 1;
|
||||
}
|
||||
$this->options = $options['options'] ?? [];
|
||||
// unsetting the property forces the first access to go through
|
||||
// __get().
|
||||
unset($this->_mh);
|
||||
}
|
||||
/**
|
||||
* @param string $name
|
||||
|
||||
@@ -13,9 +13,9 @@ final class HeaderProcessor
|
||||
*
|
||||
* @param string[] $headers
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*
|
||||
* @return array{0:string, 1:int, 2:?string, 3:array}
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public static function parseHeaders(array $headers) : array
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ class StreamHandler
|
||||
// Determine if the error was a networking error.
|
||||
$message = $e->getMessage();
|
||||
// This list can probably get more comprehensive.
|
||||
if (\false !== \strpos($message, 'getaddrinfo') || \false !== \strpos($message, 'Connection refused') || \false !== \strpos($message, "couldn't connect to host") || \false !== \strpos($message, "connection attempt failed")) {
|
||||
if (\false !== \strpos($message, 'getaddrinfo') || \false !== \strpos($message, 'Connection refused') || \false !== \strpos($message, "couldn't connect to host") || \false !== \strpos($message, 'connection attempt failed')) {
|
||||
$e = new \WPMailSMTP\Vendor\GuzzleHttp\Exception\ConnectException($e->getMessage(), $request, $e);
|
||||
} else {
|
||||
$e = \WPMailSMTP\Vendor\GuzzleHttp\Exception\RequestException::wrapException($request, $e);
|
||||
@@ -290,7 +290,7 @@ class StreamHandler
|
||||
}
|
||||
$context = ['http' => ['method' => $request->getMethod(), 'header' => $headers, 'protocol_version' => $request->getProtocolVersion(), 'ignore_errors' => \true, 'follow_location' => 0], 'ssl' => ['peer_name' => $request->getUri()->getHost()]];
|
||||
$body = (string) $request->getBody();
|
||||
if (!empty($body)) {
|
||||
if ('' !== $body) {
|
||||
$context['http']['content'] = $body;
|
||||
// Prevent the HTTP handler from adding a Content-Type header.
|
||||
if (!$request->hasHeader('Content-Type')) {
|
||||
@@ -355,6 +355,17 @@ class StreamHandler
|
||||
$options['http']['timeout'] = $value;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param mixed $value as passed via Request transfer options.
|
||||
*/
|
||||
private function add_crypto_method(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, array &$options, $value, array &$params) : void
|
||||
{
|
||||
if ($value === \STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT || $value === \STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT || $value === \STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT || \defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && $value === \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT) {
|
||||
$options['http']['crypto_method'] = $value;
|
||||
return;
|
||||
}
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided');
|
||||
}
|
||||
/**
|
||||
* @param mixed $value as passed via Request transfer options.
|
||||
*/
|
||||
|
||||
@@ -40,7 +40,7 @@ class HandlerStack
|
||||
* handler is provided, the best handler for your
|
||||
* system will be utilized.
|
||||
*/
|
||||
public static function create(?callable $handler = null) : self
|
||||
public static function create(callable $handler = null) : self
|
||||
{
|
||||
$stack = new self($handler ?: \WPMailSMTP\Vendor\GuzzleHttp\Utils::chooseHandler());
|
||||
$stack->push(\WPMailSMTP\Vendor\GuzzleHttp\Middleware::httpErrors(), 'http_errors');
|
||||
@@ -76,13 +76,13 @@ class HandlerStack
|
||||
$depth = 0;
|
||||
$stack = [];
|
||||
if ($this->handler !== null) {
|
||||
$stack[] = "0) Handler: " . $this->debugCallable($this->handler);
|
||||
$stack[] = '0) Handler: ' . $this->debugCallable($this->handler);
|
||||
}
|
||||
$result = '';
|
||||
foreach (\array_reverse($this->stack) as $tuple) {
|
||||
$depth++;
|
||||
++$depth;
|
||||
$str = "{$depth}) Name: '{$tuple[1]}', ";
|
||||
$str .= "Function: " . $this->debugCallable($tuple[0]);
|
||||
$str .= 'Function: ' . $this->debugCallable($tuple[0]);
|
||||
$result = "> {$str}\n{$result}";
|
||||
$stack[] = $str;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ class HandlerStack
|
||||
* @param callable(callable): callable $middleware Middleware function
|
||||
* @param string $name Name to register for this middleware.
|
||||
*/
|
||||
public function unshift(callable $middleware, ?string $name = null) : void
|
||||
public function unshift(callable $middleware, string $name = null) : void
|
||||
{
|
||||
\array_unshift($this->stack, [$middleware, $name]);
|
||||
$this->cached = null;
|
||||
|
||||
@@ -39,11 +39,11 @@ class MessageFormatter implements \WPMailSMTP\Vendor\GuzzleHttp\MessageFormatter
|
||||
/**
|
||||
* Apache Common Log Format.
|
||||
*
|
||||
* @link https://httpd.apache.org/docs/2.4/logs.html#common
|
||||
* @see https://httpd.apache.org/docs/2.4/logs.html#common
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public const CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}";
|
||||
public const CLF = '{hostname} {req_header_User-Agent} - [{date_common_log}] "{method} {target} HTTP/{version}" {code} {res_header_Content-Length}';
|
||||
public const DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}";
|
||||
public const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}';
|
||||
/**
|
||||
@@ -64,7 +64,7 @@ class MessageFormatter implements \WPMailSMTP\Vendor\GuzzleHttp\MessageFormatter
|
||||
* @param ResponseInterface|null $response Response that was received
|
||||
* @param \Throwable|null $error Exception that was received
|
||||
*/
|
||||
public function format(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, ?\WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, ?\Throwable $error = null) : string
|
||||
public function format(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, \Throwable $error = null) : string
|
||||
{
|
||||
$cache = [];
|
||||
/** @var string */
|
||||
|
||||
@@ -13,5 +13,5 @@ interface MessageFormatterInterface
|
||||
* @param ResponseInterface|null $response Response that was received
|
||||
* @param \Throwable|null $error Exception that was received
|
||||
*/
|
||||
public function format(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, ?\WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, ?\Throwable $error = null) : string;
|
||||
public function format(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, \Throwable $error = null) : string;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ namespace WPMailSMTP\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/.
|
||||
*
|
||||
* @link http://docs.guzzlephp.org/en/v6/request-options.html
|
||||
* @see https://docs.guzzlephp.org/en/latest/request-options.html
|
||||
*/
|
||||
final class RequestOptions
|
||||
{
|
||||
@@ -65,9 +63,20 @@ final class RequestOptions
|
||||
/**
|
||||
* connect_timeout: (float, default=0) Float describing the number of
|
||||
* seconds to wait while trying to connect to a server. Use 0 to wait
|
||||
* indefinitely (the default behavior).
|
||||
* 300 seconds (the default behavior).
|
||||
*/
|
||||
public const CONNECT_TIMEOUT = 'connect_timeout';
|
||||
/**
|
||||
* crypto_method: (int) A value describing the minimum TLS protocol
|
||||
* version to use.
|
||||
*
|
||||
* This setting must be set to one of the
|
||||
* ``STREAM_CRYPTO_METHOD_TLS*_CLIENT`` constants. PHP 7.4 or higher is
|
||||
* required in order to use TLS 1.3, and cURL 7.34.0 or higher is required
|
||||
* in order to specify a crypto method, with cURL 7.52.0 or higher being
|
||||
* required to use TLS 1.3.
|
||||
*/
|
||||
public const CRYPTO_METHOD = 'crypto_method';
|
||||
/**
|
||||
* debug: (bool|resource) Set to true or set to a PHP stream returned by
|
||||
* fopen() enable debug output with the HTTP handler used to send a
|
||||
|
||||
@@ -49,7 +49,7 @@ class RetryMiddleware
|
||||
*/
|
||||
public static function exponentialDelay(int $retries) : int
|
||||
{
|
||||
return (int) \pow(2, $retries - 1) * 1000;
|
||||
return (int) 2 ** ($retries - 1) * 1000;
|
||||
}
|
||||
public function __invoke(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, array $options) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
@@ -85,7 +85,7 @@ class RetryMiddleware
|
||||
}
|
||||
private function doRetry(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, array $options, \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
$options['delay'] = ($this->delay)(++$options['retries'], $response);
|
||||
$options['delay'] = ($this->delay)(++$options['retries'], $response, $request);
|
||||
return $this($request, $options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ final class TransferStats
|
||||
* @param mixed $handlerErrorData Handler error data.
|
||||
* @param array $handlerStats Handler specific stats.
|
||||
*/
|
||||
public function __construct(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, ?\WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, ?float $transferTime = null, $handlerErrorData = null, array $handlerStats = [])
|
||||
public function __construct(\WPMailSMTP\Vendor\Psr\Http\Message\RequestInterface $request, \WPMailSMTP\Vendor\Psr\Http\Message\ResponseInterface $response = null, float $transferTime = null, $handlerErrorData = null, array $handlerStats = [])
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
|
||||
@@ -71,19 +71,21 @@ final class Utils
|
||||
*
|
||||
* The returned handler is not wrapped by any default middlewares.
|
||||
*
|
||||
* @throws \RuntimeException if no viable Handler is available.
|
||||
*
|
||||
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
|
||||
*
|
||||
* @throws \RuntimeException if no viable Handler is available.
|
||||
*/
|
||||
public static function chooseHandler() : callable
|
||||
{
|
||||
$handler = null;
|
||||
if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
|
||||
$handler = \WPMailSMTP\Vendor\GuzzleHttp\Handler\Proxy::wrapSync(new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlMultiHandler(), new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlHandler());
|
||||
} elseif (\function_exists('curl_exec')) {
|
||||
$handler = new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlHandler();
|
||||
} elseif (\function_exists('curl_multi_exec')) {
|
||||
$handler = new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlMultiHandler();
|
||||
if (\defined('CURLOPT_CUSTOMREQUEST')) {
|
||||
if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
|
||||
$handler = \WPMailSMTP\Vendor\GuzzleHttp\Handler\Proxy::wrapSync(new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlMultiHandler(), new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlHandler());
|
||||
} elseif (\function_exists('curl_exec')) {
|
||||
$handler = new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlHandler();
|
||||
} elseif (\function_exists('curl_multi_exec')) {
|
||||
$handler = new \WPMailSMTP\Vendor\GuzzleHttp\Handler\CurlMultiHandler();
|
||||
}
|
||||
}
|
||||
if (\ini_get('allow_url_fopen')) {
|
||||
$handler = $handler ? \WPMailSMTP\Vendor\GuzzleHttp\Handler\Proxy::wrapStreaming($handler, new \WPMailSMTP\Vendor\GuzzleHttp\Handler\StreamHandler()) : new \WPMailSMTP\Vendor\GuzzleHttp\Handler\StreamHandler();
|
||||
@@ -153,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
|
||||
);
|
||||
}
|
||||
@@ -237,7 +238,7 @@ EOT
|
||||
*
|
||||
* @throws InvalidArgumentException if the JSON cannot be decoded.
|
||||
*
|
||||
* @link https://www.php.net/manual/en/function.json-decode.php
|
||||
* @see https://www.php.net/manual/en/function.json-decode.php
|
||||
*/
|
||||
public static function jsonDecode(string $json, bool $assoc = \false, int $depth = 512, int $options = 0)
|
||||
{
|
||||
@@ -256,7 +257,7 @@ EOT
|
||||
*
|
||||
* @throws InvalidArgumentException if the JSON cannot be encoded.
|
||||
*
|
||||
* @link https://www.php.net/manual/en/function.json-encode.php
|
||||
* @see https://www.php.net/manual/en/function.json-encode.php
|
||||
*/
|
||||
public static function jsonEncode($value, int $options = 0, int $depth = 512) : string
|
||||
{
|
||||
|
||||
@@ -47,10 +47,10 @@ function debug_resource($value = null)
|
||||
*
|
||||
* The returned handler is not wrapped by any default middlewares.
|
||||
*
|
||||
* @throws \RuntimeException if no viable Handler is available.
|
||||
*
|
||||
* @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
|
||||
*
|
||||
* @throws \RuntimeException if no viable Handler is available.
|
||||
*
|
||||
* @deprecated choose_handler will be removed in guzzlehttp/guzzle:8.0. Use Utils::chooseHandler instead.
|
||||
*/
|
||||
function choose_handler() : callable
|
||||
@@ -133,7 +133,7 @@ function is_host_in_noproxy(string $host, array $noProxyArray) : bool
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException if the JSON cannot be decoded.
|
||||
*
|
||||
* @link https://www.php.net/manual/en/function.json-decode.php
|
||||
* @see https://www.php.net/manual/en/function.json-decode.php
|
||||
* @deprecated json_decode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonDecode instead.
|
||||
*/
|
||||
function json_decode(string $json, bool $assoc = \false, int $depth = 512, int $options = 0)
|
||||
@@ -149,7 +149,7 @@ function json_decode(string $json, bool $assoc = \false, int $depth = 512, int $
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException if the JSON cannot be encoded.
|
||||
*
|
||||
* @link https://www.php.net/manual/en/function.json-encode.php
|
||||
* @see https://www.php.net/manual/en/function.json-encode.php
|
||||
* @deprecated json_encode will be removed in guzzlehttp/guzzle:8.0. Use Utils::jsonEncode instead.
|
||||
*/
|
||||
function json_encode($value, int $options = 0, int $depth = 512) : string
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -7,7 +8,7 @@ namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
*/
|
||||
class AggregateException extends \WPMailSMTP\Vendor\GuzzleHttp\Promise\RejectionException
|
||||
{
|
||||
public function __construct($msg, array $reasons)
|
||||
public function __construct(string $msg, array $reasons)
|
||||
{
|
||||
parent::__construct($reasons, \sprintf('%s; %d rejected promises', $msg, \count($reasons)));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
use Exception;
|
||||
use Generator;
|
||||
use Throwable;
|
||||
/**
|
||||
@@ -26,7 +26,7 @@ use Throwable;
|
||||
* $value = (yield createPromise('a'));
|
||||
* try {
|
||||
* $value = (yield createPromise($value . 'b'));
|
||||
* } catch (\Exception $e) {
|
||||
* } catch (\Throwable $e) {
|
||||
* // The promise was rejected.
|
||||
* }
|
||||
* yield $value . 'c';
|
||||
@@ -39,7 +39,7 @@ use Throwable;
|
||||
*
|
||||
* @return Promise
|
||||
*
|
||||
* @link https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration
|
||||
* @see https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration
|
||||
*/
|
||||
final class Coroutine implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
@@ -58,65 +58,61 @@ final class Coroutine implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
public function __construct(callable $generatorFn)
|
||||
{
|
||||
$this->generator = $generatorFn();
|
||||
$this->result = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise(function () {
|
||||
$this->result = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise(function () : void {
|
||||
while (isset($this->currentPromise)) {
|
||||
$this->currentPromise->wait();
|
||||
}
|
||||
});
|
||||
try {
|
||||
$this->nextCoroutine($this->generator->current());
|
||||
} catch (\Exception $exception) {
|
||||
$this->result->reject($exception);
|
||||
} catch (\Throwable $throwable) {
|
||||
$this->result->reject($throwable);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Create a new coroutine.
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function of(callable $generatorFn)
|
||||
public static function of(callable $generatorFn) : self
|
||||
{
|
||||
return new self($generatorFn);
|
||||
}
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return $this->result->then($onFulfilled, $onRejected);
|
||||
}
|
||||
public function otherwise(callable $onRejected)
|
||||
public function otherwise(callable $onRejected) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return $this->result->otherwise($onRejected);
|
||||
}
|
||||
public function wait($unwrap = \true)
|
||||
public function wait(bool $unwrap = \true)
|
||||
{
|
||||
return $this->result->wait($unwrap);
|
||||
}
|
||||
public function getState()
|
||||
public function getState() : string
|
||||
{
|
||||
return $this->result->getState();
|
||||
}
|
||||
public function resolve($value)
|
||||
public function resolve($value) : void
|
||||
{
|
||||
$this->result->resolve($value);
|
||||
}
|
||||
public function reject($reason)
|
||||
public function reject($reason) : void
|
||||
{
|
||||
$this->result->reject($reason);
|
||||
}
|
||||
public function cancel()
|
||||
public function cancel() : void
|
||||
{
|
||||
$this->currentPromise->cancel();
|
||||
$this->result->cancel();
|
||||
}
|
||||
private function nextCoroutine($yielded)
|
||||
private function nextCoroutine($yielded) : void
|
||||
{
|
||||
$this->currentPromise = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::promiseFor($yielded)->then([$this, '_handleSuccess'], [$this, '_handleFailure']);
|
||||
}
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _handleSuccess($value)
|
||||
public function _handleSuccess($value) : void
|
||||
{
|
||||
unset($this->currentPromise);
|
||||
try {
|
||||
@@ -126,8 +122,6 @@ final class Coroutine implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
} else {
|
||||
$this->result->resolve($value);
|
||||
}
|
||||
} catch (\Exception $exception) {
|
||||
$this->result->reject($exception);
|
||||
} catch (\Throwable $throwable) {
|
||||
$this->result->reject($throwable);
|
||||
}
|
||||
@@ -135,15 +129,13 @@ final class Coroutine implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
public function _handleFailure($reason)
|
||||
public function _handleFailure($reason) : void
|
||||
{
|
||||
unset($this->currentPromise);
|
||||
try {
|
||||
$nextYield = $this->generator->throw(\WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::exceptionFor($reason));
|
||||
// The throw was caught, so keep iterating on the coroutine
|
||||
$this->nextCoroutine($nextYield);
|
||||
} catch (\Exception $exception) {
|
||||
$this->result->reject($exception);
|
||||
} catch (\Throwable $throwable) {
|
||||
$this->result->reject($throwable);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
final class Create
|
||||
@@ -8,10 +9,8 @@ final class Create
|
||||
* Creates a promise for a value if the value is not a promise.
|
||||
*
|
||||
* @param mixed $value Promise or value.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function promiseFor($value)
|
||||
public static function promiseFor($value) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
if ($value instanceof \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface) {
|
||||
return $value;
|
||||
@@ -31,10 +30,8 @@ final class Create
|
||||
* If the provided reason is a promise, then it is returned as-is.
|
||||
*
|
||||
* @param mixed $reason Promise or reason.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function rejectionFor($reason)
|
||||
public static function rejectionFor($reason) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
if ($reason instanceof \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface) {
|
||||
return $reason;
|
||||
@@ -45,12 +42,10 @@ final class Create
|
||||
* Create an exception for a rejected promise value.
|
||||
*
|
||||
* @param mixed $reason
|
||||
*
|
||||
* @return \Exception|\Throwable
|
||||
*/
|
||||
public static function exceptionFor($reason)
|
||||
public static function exceptionFor($reason) : \Throwable
|
||||
{
|
||||
if ($reason instanceof \Exception || $reason instanceof \Throwable) {
|
||||
if ($reason instanceof \Throwable) {
|
||||
return $reason;
|
||||
}
|
||||
return new \WPMailSMTP\Vendor\GuzzleHttp\Promise\RejectionException($reason);
|
||||
@@ -59,10 +54,8 @@ final class Create
|
||||
* Returns an iterator for the given value.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return \Iterator
|
||||
*/
|
||||
public static function iterFor($value)
|
||||
public static function iterFor($value) : \Iterator
|
||||
{
|
||||
if ($value instanceof \Iterator) {
|
||||
return $value;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
final class Each
|
||||
@@ -17,13 +18,9 @@ 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
|
||||
*
|
||||
* @return PromiseInterface
|
||||
* @param mixed $iterable Iterator or array to iterate over.
|
||||
*/
|
||||
public static function of($iterable, callable $onFulfilled = null, callable $onRejected = null)
|
||||
public static function of($iterable, callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return (new \WPMailSMTP\Vendor\GuzzleHttp\Promise\EachPromise($iterable, ['fulfilled' => $onFulfilled, 'rejected' => $onRejected]))->promise();
|
||||
}
|
||||
@@ -37,12 +34,8 @@ final class Each
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
* @param callable $onRejected
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function ofLimit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null)
|
||||
public static function ofLimit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return (new \WPMailSMTP\Vendor\GuzzleHttp\Promise\EachPromise($iterable, ['fulfilled' => $onFulfilled, 'rejected' => $onRejected, 'concurrency' => $concurrency]))->promise();
|
||||
}
|
||||
@@ -53,13 +46,10 @@ final class Each
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function ofLimitAll($iterable, $concurrency, callable $onFulfilled = null)
|
||||
public static function ofLimitAll($iterable, $concurrency, callable $onFulfilled = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return self::ofLimit($iterable, $concurrency, $onFulfilled, function ($reason, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $aggregate) {
|
||||
return self::ofLimit($iterable, $concurrency, $onFulfilled, function ($reason, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $aggregate) : void {
|
||||
$aggregate->reject($reason);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
* Represents a promise that iterates over many promises and invokes
|
||||
* side-effect functions in the process.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInterface
|
||||
{
|
||||
@@ -57,7 +60,7 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
}
|
||||
}
|
||||
/** @psalm-suppress InvalidNullableReturnType */
|
||||
public function promise()
|
||||
public function promise() : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
if ($this->aggregate) {
|
||||
return $this->aggregate;
|
||||
@@ -69,19 +72,16 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
$this->refillPending();
|
||||
} catch (\Throwable $e) {
|
||||
$this->aggregate->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
$this->aggregate->reject($e);
|
||||
}
|
||||
/**
|
||||
* @psalm-suppress NullableReturnStatement
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
return $this->aggregate;
|
||||
}
|
||||
private function createPromise()
|
||||
private function createPromise() : void
|
||||
{
|
||||
$this->mutex = \false;
|
||||
$this->aggregate = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise(function () {
|
||||
$this->aggregate = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise(function () : void {
|
||||
if ($this->checkIfFinished()) {
|
||||
return;
|
||||
}
|
||||
@@ -97,14 +97,14 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
}
|
||||
});
|
||||
// Clear the references when the promise is resolved.
|
||||
$clearFn = function () {
|
||||
$clearFn = function () : void {
|
||||
$this->iterable = $this->concurrency = $this->pending = null;
|
||||
$this->onFulfilled = $this->onRejected = null;
|
||||
$this->nextPendingIndex = 0;
|
||||
};
|
||||
$this->aggregate->then($clearFn, $clearFn);
|
||||
}
|
||||
private function refillPending()
|
||||
private function refillPending() : void
|
||||
{
|
||||
if (!$this->concurrency) {
|
||||
// Add all pending promises.
|
||||
@@ -113,7 +113,7 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
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) {
|
||||
@@ -128,7 +128,7 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
while (--$concurrency && $this->advanceIterator() && $this->addPending()) {
|
||||
}
|
||||
}
|
||||
private function addPending()
|
||||
private function addPending() : bool
|
||||
{
|
||||
if (!$this->iterable || !$this->iterable->valid()) {
|
||||
return \false;
|
||||
@@ -138,20 +138,20 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
// Iterable keys may not be unique, so we use a counter to
|
||||
// guarantee uniqueness
|
||||
$idx = $this->nextPendingIndex++;
|
||||
$this->pending[$idx] = $promise->then(function ($value) use($idx, $key) {
|
||||
$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) {
|
||||
}, 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);
|
||||
});
|
||||
return \true;
|
||||
}
|
||||
private function advanceIterator()
|
||||
private function advanceIterator() : bool
|
||||
{
|
||||
// Place a lock on the iterator so that we ensure to not recurse,
|
||||
// preventing fatal generator errors.
|
||||
@@ -167,13 +167,9 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
$this->aggregate->reject($e);
|
||||
$this->mutex = \false;
|
||||
return \false;
|
||||
} catch (\Exception $e) {
|
||||
$this->aggregate->reject($e);
|
||||
$this->mutex = \false;
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
private function step($idx)
|
||||
private function step(int $idx) : void
|
||||
{
|
||||
// If the promise was already resolved, then ignore this step.
|
||||
if (\WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::settled($this->aggregate)) {
|
||||
@@ -188,7 +184,7 @@ class EachPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromisorInter
|
||||
$this->refillPending();
|
||||
}
|
||||
}
|
||||
private function checkIfFinished()
|
||||
private function checkIfFinished() : bool
|
||||
{
|
||||
if (!$this->pending && !$this->iterable->valid()) {
|
||||
// Resolve the promise if there's nothing left to do.
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -7,10 +8,15 @@ namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
*
|
||||
* Thenning off of this promise will invoke the onFulfilled callback
|
||||
* immediately and ignore other callbacks.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class FulfilledPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
private $value;
|
||||
/**
|
||||
* @param mixed $value
|
||||
*/
|
||||
public function __construct($value)
|
||||
{
|
||||
if (\is_object($value) && \method_exists($value, 'then')) {
|
||||
@@ -18,7 +24,7 @@ class FulfilledPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseI
|
||||
}
|
||||
$this->value = $value;
|
||||
}
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
// Return itself if there is no onFulfilled function.
|
||||
if (!$onFulfilled) {
|
||||
@@ -27,42 +33,40 @@ class FulfilledPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseI
|
||||
$queue = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::queue();
|
||||
$p = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise([$queue, 'run']);
|
||||
$value = $this->value;
|
||||
$queue->add(static function () use($p, $value, $onFulfilled) {
|
||||
$queue->add(static function () use($p, $value, $onFulfilled) : void {
|
||||
if (\WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::pending($p)) {
|
||||
try {
|
||||
$p->resolve($onFulfilled($value));
|
||||
} catch (\Throwable $e) {
|
||||
$p->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
$p->reject($e);
|
||||
}
|
||||
}
|
||||
});
|
||||
return $p;
|
||||
}
|
||||
public function otherwise(callable $onRejected)
|
||||
public function otherwise(callable $onRejected) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return $this->then(null, $onRejected);
|
||||
}
|
||||
public function wait($unwrap = \true, $defaultDelivery = null)
|
||||
public function wait(bool $unwrap = \true)
|
||||
{
|
||||
return $unwrap ? $this->value : null;
|
||||
}
|
||||
public function getState()
|
||||
public function getState() : string
|
||||
{
|
||||
return self::FULFILLED;
|
||||
}
|
||||
public function resolve($value)
|
||||
public function resolve($value) : void
|
||||
{
|
||||
if ($value !== $this->value) {
|
||||
throw new \LogicException("Cannot resolve a fulfilled promise");
|
||||
throw new \LogicException('Cannot resolve a fulfilled promise');
|
||||
}
|
||||
}
|
||||
public function reject($reason)
|
||||
public function reject($reason) : void
|
||||
{
|
||||
throw new \LogicException("Cannot reject a fulfilled promise");
|
||||
throw new \LogicException('Cannot reject a fulfilled promise');
|
||||
}
|
||||
public function cancel()
|
||||
public function cancel() : void
|
||||
{
|
||||
// pass
|
||||
}
|
||||
|
||||
@@ -1,42 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
final class Is
|
||||
{
|
||||
/**
|
||||
* Returns true if a promise is pending.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function pending(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
public static function pending(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise) : bool
|
||||
{
|
||||
return $promise->getState() === \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::PENDING;
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is fulfilled or rejected.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function settled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
public static function settled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise) : bool
|
||||
{
|
||||
return $promise->getState() !== \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::PENDING;
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is fulfilled.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function fulfilled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
public static function fulfilled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise) : bool
|
||||
{
|
||||
return $promise->getState() === \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::FULFILLED;
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is rejected.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function rejected(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
public static function rejected(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise) : bool
|
||||
{
|
||||
return $promise->getState() === \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::REJECTED;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
* Promises/A+ implementation that avoids recursion when possible.
|
||||
*
|
||||
* @link https://promisesaplus.com/
|
||||
* @see https://promisesaplus.com/
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
@@ -24,7 +27,7 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$this->waitFn = $waitFn;
|
||||
$this->cancelFn = $cancelFn;
|
||||
}
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
if ($this->state === self::PENDING) {
|
||||
$p = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise(null, [$this, 'cancel']);
|
||||
@@ -43,11 +46,11 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$rejection = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::rejectionFor($this->result);
|
||||
return $onRejected ? $rejection->then(null, $onRejected) : $rejection;
|
||||
}
|
||||
public function otherwise(callable $onRejected)
|
||||
public function otherwise(callable $onRejected) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return $this->then(null, $onRejected);
|
||||
}
|
||||
public function wait($unwrap = \true)
|
||||
public function wait(bool $unwrap = \true)
|
||||
{
|
||||
$this->waitIfPending();
|
||||
if ($this->result instanceof \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface) {
|
||||
@@ -61,11 +64,11 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
throw \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::exceptionFor($this->result);
|
||||
}
|
||||
}
|
||||
public function getState()
|
||||
public function getState() : string
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
public function cancel()
|
||||
public function cancel() : void
|
||||
{
|
||||
if ($this->state !== self::PENDING) {
|
||||
return;
|
||||
@@ -78,8 +81,6 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$fn();
|
||||
} catch (\Throwable $e) {
|
||||
$this->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
$this->reject($e);
|
||||
}
|
||||
}
|
||||
// Reject the promise only if it wasn't rejected in a then callback.
|
||||
@@ -88,15 +89,15 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$this->reject(new \WPMailSMTP\Vendor\GuzzleHttp\Promise\CancellationException('Promise has been cancelled'));
|
||||
}
|
||||
}
|
||||
public function resolve($value)
|
||||
public function resolve($value) : void
|
||||
{
|
||||
$this->settle(self::FULFILLED, $value);
|
||||
}
|
||||
public function reject($reason)
|
||||
public function reject($reason) : void
|
||||
{
|
||||
$this->settle(self::REJECTED, $reason);
|
||||
}
|
||||
private function settle($state, $value)
|
||||
private function settle(string $state, $value) : void
|
||||
{
|
||||
if ($this->state !== self::PENDING) {
|
||||
// Ignore calls with the same resolution.
|
||||
@@ -123,7 +124,7 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
if (!\is_object($value) || !\method_exists($value, 'then')) {
|
||||
$id = $state === self::FULFILLED ? 1 : 2;
|
||||
// It's a success, so resolve the handlers in the queue.
|
||||
\WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::queue()->add(static function () use($id, $value, $handlers) {
|
||||
\WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::queue()->add(static function () use($id, $value, $handlers) : void {
|
||||
foreach ($handlers as $handler) {
|
||||
self::callHandler($id, $value, $handler);
|
||||
}
|
||||
@@ -133,11 +134,11 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$value->handlers = \array_merge($value->handlers, $handlers);
|
||||
} else {
|
||||
// Resolve the handlers when the forwarded promise is resolved.
|
||||
$value->then(static function ($value) use($handlers) {
|
||||
$value->then(static function ($value) use($handlers) : void {
|
||||
foreach ($handlers as $handler) {
|
||||
self::callHandler(1, $value, $handler);
|
||||
}
|
||||
}, static function ($reason) use($handlers) {
|
||||
}, static function ($reason) use($handlers) : void {
|
||||
foreach ($handlers as $handler) {
|
||||
self::callHandler(2, $reason, $handler);
|
||||
}
|
||||
@@ -151,7 +152,7 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
* @param mixed $value Value to pass to the callback.
|
||||
* @param array $handler Array of handler data (promise and callbacks).
|
||||
*/
|
||||
private static function callHandler($index, $value, array $handler)
|
||||
private static function callHandler(int $index, $value, array $handler) : void
|
||||
{
|
||||
/** @var PromiseInterface $promise */
|
||||
$promise = $handler[0];
|
||||
@@ -180,11 +181,9 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
}
|
||||
} catch (\Throwable $reason) {
|
||||
$promise->reject($reason);
|
||||
} catch (\Exception $reason) {
|
||||
$promise->reject($reason);
|
||||
}
|
||||
}
|
||||
private function waitIfPending()
|
||||
private function waitIfPending() : void
|
||||
{
|
||||
if ($this->state !== self::PENDING) {
|
||||
return;
|
||||
@@ -202,13 +201,13 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
$this->reject('Invoking the wait callback did not resolve the promise');
|
||||
}
|
||||
}
|
||||
private function invokeWaitFn()
|
||||
private function invokeWaitFn() : void
|
||||
{
|
||||
try {
|
||||
$wfn = $this->waitFn;
|
||||
$this->waitFn = null;
|
||||
$wfn(\true);
|
||||
} catch (\Exception $reason) {
|
||||
} catch (\Throwable $reason) {
|
||||
if ($this->state === self::PENDING) {
|
||||
// The promise has not been resolved yet, so reject the promise
|
||||
// with the exception.
|
||||
@@ -220,7 +219,7 @@ class Promise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
}
|
||||
}
|
||||
}
|
||||
private function invokeWaitList()
|
||||
private function invokeWaitList() : void
|
||||
{
|
||||
$waitList = $this->waitList;
|
||||
$this->waitList = null;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -9,23 +10,21 @@ namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
* which registers callbacks to receive either a promise’s eventual value or
|
||||
* the reason why the promise cannot be fulfilled.
|
||||
*
|
||||
* @link https://promisesaplus.com/
|
||||
* @see https://promisesaplus.com/
|
||||
*/
|
||||
interface PromiseInterface
|
||||
{
|
||||
const PENDING = 'pending';
|
||||
const FULFILLED = 'fulfilled';
|
||||
const REJECTED = 'rejected';
|
||||
public const PENDING = 'pending';
|
||||
public const FULFILLED = 'fulfilled';
|
||||
public const REJECTED = 'rejected';
|
||||
/**
|
||||
* Appends fulfillment and rejection handlers to the promise, and returns
|
||||
* a new promise resolving to the return value of the called handler.
|
||||
*
|
||||
* @param callable $onFulfilled Invoked when the promise fulfills.
|
||||
* @param callable $onRejected Invoked when the promise is rejected.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null);
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface;
|
||||
/**
|
||||
* Appends a rejection handler callback to the promise, and returns a new
|
||||
* promise resolving to the return value of the callback if it is called,
|
||||
@@ -33,19 +32,15 @@ interface PromiseInterface
|
||||
* fulfilled.
|
||||
*
|
||||
* @param callable $onRejected Invoked when the promise is rejected.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function otherwise(callable $onRejected);
|
||||
public function otherwise(callable $onRejected) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface;
|
||||
/**
|
||||
* Get the state of the promise ("pending", "rejected", or "fulfilled").
|
||||
*
|
||||
* The three states can be checked against the constants defined on
|
||||
* PromiseInterface: PENDING, FULFILLED, and REJECTED.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getState();
|
||||
public function getState() : string;
|
||||
/**
|
||||
* Resolve the promise with the given value.
|
||||
*
|
||||
@@ -53,7 +48,7 @@ interface PromiseInterface
|
||||
*
|
||||
* @throws \RuntimeException if the promise is already resolved.
|
||||
*/
|
||||
public function resolve($value);
|
||||
public function resolve($value) : void;
|
||||
/**
|
||||
* Reject the promise with the given reason.
|
||||
*
|
||||
@@ -61,13 +56,13 @@ interface PromiseInterface
|
||||
*
|
||||
* @throws \RuntimeException if the promise is already resolved.
|
||||
*/
|
||||
public function reject($reason);
|
||||
public function reject($reason) : void;
|
||||
/**
|
||||
* Cancels the promise if possible.
|
||||
*
|
||||
* @link https://github.com/promises-aplus/cancellation-spec/issues/7
|
||||
* @see https://github.com/promises-aplus/cancellation-spec/issues/7
|
||||
*/
|
||||
public function cancel();
|
||||
public function cancel() : void;
|
||||
/**
|
||||
* Waits until the promise completes if possible.
|
||||
*
|
||||
@@ -76,12 +71,10 @@ interface PromiseInterface
|
||||
*
|
||||
* If the promise cannot be waited on, then the promise will be rejected.
|
||||
*
|
||||
* @param bool $unwrap
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \LogicException if the promise has no wait function or if the
|
||||
* promise does not settle after waiting.
|
||||
*/
|
||||
public function wait($unwrap = \true);
|
||||
public function wait(bool $unwrap = \true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -9,8 +10,6 @@ interface PromisorInterface
|
||||
{
|
||||
/**
|
||||
* Returns a promise.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public function promise();
|
||||
public function promise() : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -7,10 +8,15 @@ namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
*
|
||||
* Thenning off of this promise will invoke the onRejected callback
|
||||
* immediately and ignore other callbacks.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class RejectedPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
private $reason;
|
||||
/**
|
||||
* @param mixed $reason
|
||||
*/
|
||||
public function __construct($reason)
|
||||
{
|
||||
if (\is_object($reason) && \method_exists($reason, 'then')) {
|
||||
@@ -18,7 +24,7 @@ class RejectedPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
}
|
||||
$this->reason = $reason;
|
||||
}
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null)
|
||||
public function then(callable $onFulfilled = null, callable $onRejected = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
// If there's no onRejected callback then just return self.
|
||||
if (!$onRejected) {
|
||||
@@ -27,7 +33,7 @@ class RejectedPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
$queue = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::queue();
|
||||
$reason = $this->reason;
|
||||
$p = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise([$queue, 'run']);
|
||||
$queue->add(static function () use($p, $reason, $onRejected) {
|
||||
$queue->add(static function () use($p, $reason, $onRejected) : void {
|
||||
if (\WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::pending($p)) {
|
||||
try {
|
||||
// Return a resolved promise if onRejected does not throw.
|
||||
@@ -35,40 +41,37 @@ class RejectedPromise implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseIn
|
||||
} catch (\Throwable $e) {
|
||||
// onRejected threw, so return a rejected promise.
|
||||
$p->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
// onRejected threw, so return a rejected promise.
|
||||
$p->reject($e);
|
||||
}
|
||||
}
|
||||
});
|
||||
return $p;
|
||||
}
|
||||
public function otherwise(callable $onRejected)
|
||||
public function otherwise(callable $onRejected) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return $this->then(null, $onRejected);
|
||||
}
|
||||
public function wait($unwrap = \true, $defaultDelivery = null)
|
||||
public function wait(bool $unwrap = \true)
|
||||
{
|
||||
if ($unwrap) {
|
||||
throw \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::exceptionFor($this->reason);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function getState()
|
||||
public function getState() : string
|
||||
{
|
||||
return self::REJECTED;
|
||||
}
|
||||
public function resolve($value)
|
||||
public function resolve($value) : void
|
||||
{
|
||||
throw new \LogicException("Cannot resolve a rejected promise");
|
||||
throw new \LogicException('Cannot resolve a rejected promise');
|
||||
}
|
||||
public function reject($reason)
|
||||
public function reject($reason) : void
|
||||
{
|
||||
if ($reason !== $this->reason) {
|
||||
throw new \LogicException("Cannot reject a rejected promise");
|
||||
throw new \LogicException('Cannot reject a rejected promise');
|
||||
}
|
||||
}
|
||||
public function cancel()
|
||||
public function cancel() : void
|
||||
{
|
||||
// pass
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -12,10 +13,10 @@ class RejectionException extends \RuntimeException
|
||||
/** @var mixed Rejection reason. */
|
||||
private $reason;
|
||||
/**
|
||||
* @param mixed $reason Rejection reason.
|
||||
* @param string $description Optional description
|
||||
* @param mixed $reason Rejection reason.
|
||||
* @param string|null $description Optional description.
|
||||
*/
|
||||
public function __construct($reason, $description = null)
|
||||
public function __construct($reason, string $description = null)
|
||||
{
|
||||
$this->reason = $reason;
|
||||
$message = 'The promise was rejected';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
@@ -10,15 +11,17 @@ namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
* by calling the `run()` function of the global task queue in an event loop.
|
||||
*
|
||||
* GuzzleHttp\Promise\Utils::queue()->run();
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class TaskQueue implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterface
|
||||
{
|
||||
private $enableShutdown = \true;
|
||||
private $queue = [];
|
||||
public function __construct($withShutdown = \true)
|
||||
public function __construct(bool $withShutdown = \true)
|
||||
{
|
||||
if ($withShutdown) {
|
||||
\register_shutdown_function(function () {
|
||||
\register_shutdown_function(function () : void {
|
||||
if ($this->enableShutdown) {
|
||||
// Only run the tasks if an E_ERROR didn't occur.
|
||||
$err = \error_get_last();
|
||||
@@ -29,15 +32,15 @@ class TaskQueue implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterf
|
||||
});
|
||||
}
|
||||
}
|
||||
public function isEmpty()
|
||||
public function isEmpty() : bool
|
||||
{
|
||||
return !$this->queue;
|
||||
}
|
||||
public function add(callable $task)
|
||||
public function add(callable $task) : void
|
||||
{
|
||||
$this->queue[] = $task;
|
||||
}
|
||||
public function run()
|
||||
public function run() : void
|
||||
{
|
||||
while ($task = \array_shift($this->queue)) {
|
||||
/** @var callable $task */
|
||||
@@ -55,7 +58,7 @@ class TaskQueue implements \WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterf
|
||||
*
|
||||
* Note: This shutdown will occur before any destructors are triggered.
|
||||
*/
|
||||
public function disableShutdown()
|
||||
public function disableShutdown() : void
|
||||
{
|
||||
$this->enableShutdown = \false;
|
||||
}
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
interface TaskQueueInterface
|
||||
{
|
||||
/**
|
||||
* Returns true if the queue is empty.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isEmpty();
|
||||
public function isEmpty() : bool;
|
||||
/**
|
||||
* Adds a task to the queue that will be executed the next time run is
|
||||
* called.
|
||||
*/
|
||||
public function add(callable $task);
|
||||
public function add(callable $task) : void;
|
||||
/**
|
||||
* Execute all of the pending task in the queue.
|
||||
*/
|
||||
public function run();
|
||||
public function run() : void;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
final class Utils
|
||||
@@ -17,11 +18,9 @@ final class Utils
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @param TaskQueueInterface $assign Optionally specify a new queue instance.
|
||||
*
|
||||
* @return TaskQueueInterface
|
||||
* @param TaskQueueInterface|null $assign Optionally specify a new queue instance.
|
||||
*/
|
||||
public static function queue(\WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterface $assign = null)
|
||||
public static function queue(\WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterface $assign = null) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterface
|
||||
{
|
||||
static $queue;
|
||||
if ($assign) {
|
||||
@@ -36,22 +35,18 @@ final class Utils
|
||||
* returns a promise that is fulfilled or rejected with the result.
|
||||
*
|
||||
* @param callable $task Task function to run.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function task(callable $task)
|
||||
public static function task(callable $task) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
$queue = self::queue();
|
||||
$promise = new \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise([$queue, 'run']);
|
||||
$queue->add(function () use($task, $promise) {
|
||||
$queue->add(function () use($task, $promise) : void {
|
||||
try {
|
||||
if (\WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::pending($promise)) {
|
||||
$promise->resolve($task());
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$promise->reject($e);
|
||||
} catch (\Exception $e) {
|
||||
$promise->reject($e);
|
||||
}
|
||||
});
|
||||
return $promise;
|
||||
@@ -67,10 +62,8 @@ final class Utils
|
||||
* key mapping to the rejection reason of the promise.
|
||||
*
|
||||
* @param PromiseInterface $promise Promise or value.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function inspect(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
public static function inspect(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise) : array
|
||||
{
|
||||
try {
|
||||
return ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::FULFILLED, 'value' => $promise->wait()];
|
||||
@@ -78,8 +71,6 @@ final class Utils
|
||||
return ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $e->getReason()];
|
||||
} catch (\Throwable $e) {
|
||||
return ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $e];
|
||||
} catch (\Exception $e) {
|
||||
return ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $e];
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -91,10 +82,8 @@ final class Utils
|
||||
* @see inspect for the inspection state array format.
|
||||
*
|
||||
* @param PromiseInterface[] $promises Traversable of promises to wait upon.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function inspectAll($promises)
|
||||
public static function inspectAll($promises) : array
|
||||
{
|
||||
$results = [];
|
||||
foreach ($promises as $key => $promise) {
|
||||
@@ -111,12 +100,9 @@ final class Utils
|
||||
*
|
||||
* @param iterable<PromiseInterface> $promises Iterable of PromiseInterface objects to wait on.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception on error
|
||||
* @throws \Throwable on error in PHP >=7
|
||||
* @throws \Throwable on error
|
||||
*/
|
||||
public static function unwrap($promises)
|
||||
public static function unwrap($promises) : array
|
||||
{
|
||||
$results = [];
|
||||
foreach ($promises as $key => $promise) {
|
||||
@@ -134,15 +120,13 @@ final class Utils
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
* @param bool $recursive If true, resolves new promises that might have been added to the stack during its own resolution.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function all($promises, $recursive = \false)
|
||||
public static function all($promises, bool $recursive = \false) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
$results = [];
|
||||
$promise = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx) use(&$results) {
|
||||
$promise = \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx) use(&$results) : void {
|
||||
$results[$idx] = $value;
|
||||
}, function ($reason, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise $aggregate) {
|
||||
}, function ($reason, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\Promise $aggregate) : void {
|
||||
$aggregate->reject($reason);
|
||||
})->then(function () use(&$results) {
|
||||
\ksort($results);
|
||||
@@ -173,14 +157,12 @@ final class Utils
|
||||
*
|
||||
* @param int $count Total number of promises.
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function some($count, $promises)
|
||||
public static function some(int $count, $promises) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
$results = [];
|
||||
$rejections = [];
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $p) use(&$results, $count) {
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx, \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $p) use(&$results, $count) : void {
|
||||
if (\WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::settled($p)) {
|
||||
return;
|
||||
}
|
||||
@@ -188,7 +170,7 @@ final class Utils
|
||||
if (\count($results) >= $count) {
|
||||
$p->resolve(null);
|
||||
}
|
||||
}, function ($reason) use(&$rejections) {
|
||||
}, function ($reason) use(&$rejections) : void {
|
||||
$rejections[] = $reason;
|
||||
})->then(function () use(&$results, &$rejections, $count) {
|
||||
if (\count($results) !== $count) {
|
||||
@@ -203,10 +185,8 @@ final class Utils
|
||||
* fulfillment value is not an array of 1 but the value directly.
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function any($promises)
|
||||
public static function any($promises) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
return self::some(1, $promises)->then(function ($values) {
|
||||
return $values[0];
|
||||
@@ -221,15 +201,13 @@ final class Utils
|
||||
* @see inspect for the inspection state array format.
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*/
|
||||
public static function settle($promises)
|
||||
public static function settle($promises) : \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface
|
||||
{
|
||||
$results = [];
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx) use(&$results) {
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($promises, function ($value, $idx) use(&$results) : void {
|
||||
$results[$idx] = ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::FULFILLED, 'value' => $value];
|
||||
}, function ($reason, $idx) use(&$results) {
|
||||
}, function ($reason, $idx) use(&$results) : void {
|
||||
$results[$idx] = ['state' => \WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface::REJECTED, 'reason' => $reason];
|
||||
})->then(function () use(&$results) {
|
||||
\ksort($results);
|
||||
|
||||
@@ -1,334 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor\GuzzleHttp\Promise;
|
||||
|
||||
/**
|
||||
* Get the global task queue used for promise resolution.
|
||||
*
|
||||
* This task queue MUST be run in an event loop in order for promises to be
|
||||
* settled asynchronously. It will be automatically run when synchronously
|
||||
* waiting on a promise.
|
||||
*
|
||||
* <code>
|
||||
* while ($eventLoop->isRunning()) {
|
||||
* GuzzleHttp\Promise\queue()->run();
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @param TaskQueueInterface $assign Optionally specify a new queue instance.
|
||||
*
|
||||
* @return TaskQueueInterface
|
||||
*
|
||||
* @deprecated queue will be removed in guzzlehttp/promises:2.0. Use Utils::queue instead.
|
||||
*/
|
||||
function queue(\WPMailSMTP\Vendor\GuzzleHttp\Promise\TaskQueueInterface $assign = null)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::queue($assign);
|
||||
}
|
||||
/**
|
||||
* Adds a function to run in the task queue when it is next `run()` and returns
|
||||
* a promise that is fulfilled or rejected with the result.
|
||||
*
|
||||
* @param callable $task Task function to run.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated task will be removed in guzzlehttp/promises:2.0. Use Utils::task instead.
|
||||
*/
|
||||
function task(callable $task)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::task($task);
|
||||
}
|
||||
/**
|
||||
* Creates a promise for a value if the value is not a promise.
|
||||
*
|
||||
* @param mixed $value Promise or value.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated promise_for will be removed in guzzlehttp/promises:2.0. Use Create::promiseFor instead.
|
||||
*/
|
||||
function promise_for($value)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::promiseFor($value);
|
||||
}
|
||||
/**
|
||||
* Creates a rejected promise for a reason if the reason is not a promise. If
|
||||
* the provided reason is a promise, then it is returned as-is.
|
||||
*
|
||||
* @param mixed $reason Promise or reason.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated rejection_for will be removed in guzzlehttp/promises:2.0. Use Create::rejectionFor instead.
|
||||
*/
|
||||
function rejection_for($reason)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::rejectionFor($reason);
|
||||
}
|
||||
/**
|
||||
* Create an exception for a rejected promise value.
|
||||
*
|
||||
* @param mixed $reason
|
||||
*
|
||||
* @return \Exception|\Throwable
|
||||
*
|
||||
* @deprecated exception_for will be removed in guzzlehttp/promises:2.0. Use Create::exceptionFor instead.
|
||||
*/
|
||||
function exception_for($reason)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::exceptionFor($reason);
|
||||
}
|
||||
/**
|
||||
* Returns an iterator for the given value.
|
||||
*
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return \Iterator
|
||||
*
|
||||
* @deprecated iter_for will be removed in guzzlehttp/promises:2.0. Use Create::iterFor instead.
|
||||
*/
|
||||
function iter_for($value)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Create::iterFor($value);
|
||||
}
|
||||
/**
|
||||
* Synchronously waits on a promise to resolve and returns an inspection state
|
||||
* array.
|
||||
*
|
||||
* Returns a state associative array containing a "state" key mapping to a
|
||||
* valid promise state. If the state of the promise is "fulfilled", the array
|
||||
* will contain a "value" key mapping to the fulfilled value of the promise. If
|
||||
* the promise is rejected, the array will contain a "reason" key mapping to
|
||||
* the rejection reason of the promise.
|
||||
*
|
||||
* @param PromiseInterface $promise Promise or value.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @deprecated inspect will be removed in guzzlehttp/promises:2.0. Use Utils::inspect instead.
|
||||
*/
|
||||
function inspect(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::inspect($promise);
|
||||
}
|
||||
/**
|
||||
* Waits on all of the provided promises, but does not unwrap rejected promises
|
||||
* as thrown exception.
|
||||
*
|
||||
* Returns an array of inspection state arrays.
|
||||
*
|
||||
* @see inspect for the inspection state array format.
|
||||
*
|
||||
* @param PromiseInterface[] $promises Traversable of promises to wait upon.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @deprecated inspect will be removed in guzzlehttp/promises:2.0. Use Utils::inspectAll instead.
|
||||
*/
|
||||
function inspect_all($promises)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::inspectAll($promises);
|
||||
}
|
||||
/**
|
||||
* Waits on all of the provided promises and returns the fulfilled values.
|
||||
*
|
||||
* Returns an array that contains the value of each promise (in the same order
|
||||
* the promises were provided). An exception is thrown if any of the promises
|
||||
* are rejected.
|
||||
*
|
||||
* @param iterable<PromiseInterface> $promises Iterable of PromiseInterface objects to wait on.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \Exception on error
|
||||
* @throws \Throwable on error in PHP >=7
|
||||
*
|
||||
* @deprecated unwrap will be removed in guzzlehttp/promises:2.0. Use Utils::unwrap instead.
|
||||
*/
|
||||
function unwrap($promises)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::unwrap($promises);
|
||||
}
|
||||
/**
|
||||
* Given an array of promises, return a promise that is fulfilled when all the
|
||||
* items in the array are fulfilled.
|
||||
*
|
||||
* The promise's fulfillment value is an array with fulfillment values at
|
||||
* respective positions to the original array. If any promise in the array
|
||||
* rejects, the returned promise is rejected with the rejection reason.
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
* @param bool $recursive If true, resolves new promises that might have been added to the stack during its own resolution.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated all will be removed in guzzlehttp/promises:2.0. Use Utils::all instead.
|
||||
*/
|
||||
function all($promises, $recursive = \false)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::all($promises, $recursive);
|
||||
}
|
||||
/**
|
||||
* Initiate a competitive race between multiple promises or values (values will
|
||||
* become immediately fulfilled promises).
|
||||
*
|
||||
* When count amount of promises have been fulfilled, the returned promise is
|
||||
* fulfilled with an array that contains the fulfillment values of the winners
|
||||
* in order of resolution.
|
||||
*
|
||||
* This promise is rejected with a {@see AggregateException} if the number of
|
||||
* fulfilled promises is less than the desired $count.
|
||||
*
|
||||
* @param int $count Total number of promises.
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated some will be removed in guzzlehttp/promises:2.0. Use Utils::some instead.
|
||||
*/
|
||||
function some($count, $promises)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::some($count, $promises);
|
||||
}
|
||||
/**
|
||||
* Like some(), with 1 as count. However, if the promise fulfills, the
|
||||
* fulfillment value is not an array of 1 but the value directly.
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated any will be removed in guzzlehttp/promises:2.0. Use Utils::any instead.
|
||||
*/
|
||||
function any($promises)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::any($promises);
|
||||
}
|
||||
/**
|
||||
* Returns a promise that is fulfilled when all of the provided promises have
|
||||
* been fulfilled or rejected.
|
||||
*
|
||||
* The returned promise is fulfilled with an array of inspection state arrays.
|
||||
*
|
||||
* @see inspect for the inspection state array format.
|
||||
*
|
||||
* @param mixed $promises Promises or values.
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated settle will be removed in guzzlehttp/promises:2.0. Use Utils::settle instead.
|
||||
*/
|
||||
function settle($promises)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Utils::settle($promises);
|
||||
}
|
||||
/**
|
||||
* Given an iterator that yields promises or values, returns a promise that is
|
||||
* fulfilled with a null value when the iterator has been consumed or the
|
||||
* aggregate promise has been fulfilled or rejected.
|
||||
*
|
||||
* $onFulfilled is a function that accepts the fulfilled value, iterator index,
|
||||
* and the aggregate promise. The callback can invoke any necessary side
|
||||
* effects and choose to resolve or reject the aggregate if needed.
|
||||
*
|
||||
* $onRejected is a function that accepts the rejection reason, iterator 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
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated each will be removed in guzzlehttp/promises:2.0. Use Each::of instead.
|
||||
*/
|
||||
function each($iterable, callable $onFulfilled = null, callable $onRejected = null)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::of($iterable, $onFulfilled, $onRejected);
|
||||
}
|
||||
/**
|
||||
* Like each, but only allows a certain number of outstanding promises at any
|
||||
* given time.
|
||||
*
|
||||
* $concurrency may be an integer or a function that accepts the number of
|
||||
* pending promises and returns a numeric concurrency limit value to allow for
|
||||
* dynamic a concurrency size.
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
* @param callable $onRejected
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated each_limit will be removed in guzzlehttp/promises:2.0. Use Each::ofLimit instead.
|
||||
*/
|
||||
function each_limit($iterable, $concurrency, callable $onFulfilled = null, callable $onRejected = null)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::ofLimit($iterable, $concurrency, $onFulfilled, $onRejected);
|
||||
}
|
||||
/**
|
||||
* Like each_limit, but ensures that no promise in the given $iterable argument
|
||||
* is rejected. If any promise is rejected, then the aggregate promise is
|
||||
* rejected with the encountered rejection.
|
||||
*
|
||||
* @param mixed $iterable
|
||||
* @param int|callable $concurrency
|
||||
* @param callable $onFulfilled
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated each_limit_all will be removed in guzzlehttp/promises:2.0. Use Each::ofLimitAll instead.
|
||||
*/
|
||||
function each_limit_all($iterable, $concurrency, callable $onFulfilled = null)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Each::ofLimitAll($iterable, $concurrency, $onFulfilled);
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is fulfilled.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated is_fulfilled will be removed in guzzlehttp/promises:2.0. Use Is::fulfilled instead.
|
||||
*/
|
||||
function is_fulfilled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::fulfilled($promise);
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is rejected.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated is_rejected will be removed in guzzlehttp/promises:2.0. Use Is::rejected instead.
|
||||
*/
|
||||
function is_rejected(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::rejected($promise);
|
||||
}
|
||||
/**
|
||||
* Returns true if a promise is fulfilled or rejected.
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @deprecated is_settled will be removed in guzzlehttp/promises:2.0. Use Is::settled instead.
|
||||
*/
|
||||
function is_settled(\WPMailSMTP\Vendor\GuzzleHttp\Promise\PromiseInterface $promise)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Is::settled($promise);
|
||||
}
|
||||
/**
|
||||
* Create a new coroutine.
|
||||
*
|
||||
* @see Coroutine
|
||||
*
|
||||
* @return PromiseInterface
|
||||
*
|
||||
* @deprecated coroutine will be removed in guzzlehttp/promises:2.0. Use Coroutine::of instead.
|
||||
*/
|
||||
function coroutine(callable $generatorFn)
|
||||
{
|
||||
return \WPMailSMTP\Vendor\GuzzleHttp\Promise\Coroutine::of($generatorFn);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace WPMailSMTP\Vendor;
|
||||
|
||||
// Don't redefine the functions if included multiple times.
|
||||
if (!\function_exists('WPMailSMTP\\Vendor\\GuzzleHttp\\Promise\\promise_for')) {
|
||||
require __DIR__ . '/functions.php';
|
||||
}
|
||||
@@ -42,7 +42,7 @@ final class FnStream implements \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterf
|
||||
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 \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterf
|
||||
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 \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterf
|
||||
}
|
||||
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 WPMailSMTP\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 \WPMailSMTP\Vendor\Psr\Http\Message\StreamInterface
|
||||
{
|
||||
@@ -24,7 +24,7 @@ final class InflateStream implements \WPMailSMTP\Vendor\Psr\Http\Message\StreamI
|
||||
{
|
||||
$resource = \WPMailSMTP\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(\WPMailSMTP\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(\WPMailSMTP\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) : \WPMailSMTP\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 \WPMailSMTP\Vendor\Psr\Http\Message\Strea
|
||||
/**
|
||||
* 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 \WPMailSMTP\Vendor\Psr\Http\Message\Strea
|
||||
$stream->addStream($body);
|
||||
$stream->addStream(\WPMailSMTP\Vendor\GuzzleHttp\Psr7\Utils::streamFor("\r\n"));
|
||||
}
|
||||
/**
|
||||
* @param string[] $headers
|
||||
*
|
||||
* @return array{0: StreamInterface, 1: string[]}
|
||||
*/
|
||||
private function createElement(string $name, \WPMailSMTP\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'] = \WPMailSMTP\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 WPMailSMTP\Vendor\Psr\Http\Message\StreamInterface;
|
||||
*/
|
||||
final class PumpStream implements \WPMailSMTP\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 \WPMailSMTP\Vendor\Psr\Http\Message\StreamInte
|
||||
}
|
||||
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 \WPMailSMTP\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 \WPMailSMTP\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 \WPMailSMTP\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 \WPMailSMTP\Vendor\GuzzleHttp\Psr7\Request implement
|
||||
/**
|
||||
* @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 WPMailSMTP\Vendor\Psr\Http\Message\StreamInterface;
|
||||
class Stream implements \WPMailSMTP\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 \WPMailSMTP\Vendor\Psr\Http\Message\UploadedFileIn
|
||||
}
|
||||
$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 \WPMailSMTP\Vendor\Psr\Http\Message\UploadedFileIn
|
||||
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 \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
/**
|
||||
* 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 \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
* `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 \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
* @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(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -176,7 +176,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
*
|
||||
* 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(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -187,7 +187,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
*
|
||||
* 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(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -198,7 +198,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
*
|
||||
* 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(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : bool
|
||||
{
|
||||
@@ -214,7 +214,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
* @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(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri, \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $base = null) : bool
|
||||
{
|
||||
@@ -262,8 +262,8 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
*
|
||||
* 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(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri, array $keyValueArray) : \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface
|
||||
{
|
||||
@@ -276,7 +276,7 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
/**
|
||||
* 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 \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
return $port;
|
||||
}
|
||||
/**
|
||||
* @param string[] $keys
|
||||
* @param (string|int)[] $keys
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
@@ -499,7 +499,9 @@ class Uri implements \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface, \JsonSeri
|
||||
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 WPMailSMTP\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(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS) : \WPMailSMTP\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(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri1, \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS) : bool
|
||||
{
|
||||
@@ -155,7 +155,7 @@ final class UriNormalizer
|
||||
private static function capitalizePercentEncoding(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : \WPMailSMTP\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(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $uri) : \WPMailSMTP\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 WPMailSMTP\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(\WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $base, \WPMailSMTP\Vendor\Psr\Http\Message\UriInterface $rel) : \WPMailSMTP\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