← All changes
|
includes/sdk/google/guzzlehttp/guzzle/src/Client.php
+23
-23
1.2.3
→
1.4.2
View file →
| @@ -1,20 +1,20 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace Dudlewebs\WPMCS\GuzzleHttp; | |
| 3 | +namespace Dudlewebs\WPMCS\GCP\GuzzleHttp; | |
| 4 | 4 | |
| 5 | -use Dudlewebs\WPMCS\GuzzleHttp\Cookie\CookieJar; | |
| 6 | -use Dudlewebs\WPMCS\GuzzleHttp\Exception\GuzzleException; | |
| 7 | -use Dudlewebs\WPMCS\GuzzleHttp\Exception\InvalidArgumentException; | |
| 8 | -use Dudlewebs\WPMCS\GuzzleHttp\Promise as P; | |
| 9 | -use Dudlewebs\WPMCS\GuzzleHttp\Promise\PromiseInterface; | |
| 10 | -use Dudlewebs\WPMCS\Psr\Http\Message\RequestInterface; | |
| 11 | -use Dudlewebs\WPMCS\Psr\Http\Message\ResponseInterface; | |
| 12 | -use Dudlewebs\WPMCS\Psr\Http\Message\UriInterface; | |
| 5 | +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Cookie\CookieJar; | |
| 6 | +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Exception\GuzzleException; | |
| 7 | +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Exception\InvalidArgumentException; | |
| 8 | +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Promise as P; | |
| 9 | +use Dudlewebs\WPMCS\GCP\GuzzleHttp\Promise\PromiseInterface; | |
| 10 | +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\RequestInterface; | |
| 11 | +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\ResponseInterface; | |
| 12 | +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\UriInterface; | |
| 13 | 13 | /** |
| 14 | 14 | * @final |
| 15 | 15 | */ |
| 16 | -class Client implements ClientInterface, \Dudlewebs\WPMCS\Psr\Http\Client\ClientInterface | |
| 16 | +class Client implements ClientInterface, \Dudlewebs\WPMCS\GCP\Psr\Http\Client\ClientInterface | |
| 17 | 17 | { |
| 18 | 18 | use ClientTrait; |
| 19 | 19 | /** |
| 20 | 20 | * @var array Default request options |
| @@ -86,9 +86,9 @@ | ||
| 86 | 86 | * |
| 87 | 87 | * @param array $options Request options to apply to the given |
| 88 | 88 | * request and to the transfer. See \GuzzleHttp\RequestOptions. |
| 89 | 89 | */ |
| 90 | - public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface | |
| 90 | + public function sendAsync(RequestInterface $request, array $options = []) : PromiseInterface | |
| 91 | 91 | { |
| 92 | 92 | // Merge the base URI into the request URI if needed. |
| 93 | 93 | $options = $this->prepareDefaults($options); |
| 94 | 94 | return $this->transfer($request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')), $options); |
| @@ -100,9 +100,9 @@ | ||
| 100 | 100 | * request and to the transfer. See \GuzzleHttp\RequestOptions. |
| 101 | 101 | * |
| 102 | 102 | * @throws GuzzleException |
| 103 | 103 | */ |
| 104 | - public function send(RequestInterface $request, array $options = []): ResponseInterface | |
| 104 | + public function send(RequestInterface $request, array $options = []) : ResponseInterface | |
| 105 | 105 | { |
| 106 | 106 | $options[RequestOptions::SYNCHRONOUS] = \true; |
| 107 | 107 | return $this->sendAsync($request, $options)->wait(); |
| 108 | 108 | } |
| @@ -110,9 +110,9 @@ | ||
| 110 | 110 | * The HttpClient PSR (PSR-18) specify this method. |
| 111 | 111 | * |
| 112 | 112 | * {@inheritDoc} |
| 113 | 113 | */ |
| 114 | - public function sendRequest(RequestInterface $request): ResponseInterface | |
| 114 | + public function sendRequest(RequestInterface $request) : ResponseInterface | |
| 115 | 115 | { |
| 116 | 116 | $options[RequestOptions::SYNCHRONOUS] = \true; |
| 117 | 117 | $options[RequestOptions::ALLOW_REDIRECTS] = \false; |
| 118 | 118 | $options[RequestOptions::HTTP_ERRORS] = \false; |
| @@ -129,9 +129,9 @@ | ||
| 129 | 129 | * @param string $method HTTP method |
| 130 | 130 | * @param string|UriInterface $uri URI object or string. |
| 131 | 131 | * @param array $options Request options to apply. See \GuzzleHttp\RequestOptions. |
| 132 | 132 | */ |
| 133 | - public function requestAsync(string $method, $uri = '', array $options = []): PromiseInterface | |
| 133 | + public function requestAsync(string $method, $uri = '', array $options = []) : PromiseInterface | |
| 134 | 134 | { |
| 135 | 135 | $options = $this->prepareDefaults($options); |
| 136 | 136 | // Remove request modifying parameter because it can be done up-front. |
| 137 | 137 | $headers = $options['headers'] ?? []; |
| @@ -159,9 +159,9 @@ | ||
| 159 | 159 | * @param array $options Request options to apply. See \GuzzleHttp\RequestOptions. |
| 160 | 160 | * |
| 161 | 161 | * @throws GuzzleException |
| 162 | 162 | */ |
| 163 | - public function request(string $method, $uri = '', array $options = []): ResponseInterface | |
| 163 | + public function request(string $method, $uri = '', array $options = []) : ResponseInterface | |
| 164 | 164 | { |
| 165 | 165 | $options[RequestOptions::SYNCHRONOUS] = \true; |
| 166 | 166 | return $this->requestAsync($method, $uri, $options)->wait(); |
| 167 | 167 | } |
| @@ -181,9 +181,9 @@ | ||
| 181 | 181 | public function getConfig(?string $option = null) |
| 182 | 182 | { |
| 183 | 183 | return $option === null ? $this->config : $this->config[$option] ?? null; |
| 184 | 184 | } |
| 185 | - private function buildUri(UriInterface $uri, array $config): UriInterface | |
| 185 | + private function buildUri(UriInterface $uri, array $config) : UriInterface | |
| 186 | 186 | { |
| 187 | 187 | if (isset($config['base_uri'])) { |
| 188 | 188 | $uri = Psr7\UriResolver::resolve(Psr7\Utils::uriFor($config['base_uri']), $uri); |
| 189 | 189 | } |
| @@ -195,9 +195,9 @@ | ||
| 195 | 195 | } |
| 196 | 196 | /** |
| 197 | 197 | * Configures the default options for a client. |
| 198 | 198 | */ |
| 199 | - private function configureDefaults(array $config): void | |
| 199 | + private function configureDefaults(array $config) : void | |
| 200 | 200 | { |
| 201 | 201 | $defaults = ['allow_redirects' => RedirectMiddleware::$defaultSettings, 'http_errors' => \true, 'decode_content' => \true, 'verify' => \true, 'cookies' => \false, 'idn_conversion' => \false]; |
| 202 | 202 | // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set. |
| 203 | 203 | // We can only trust the HTTP_PROXY environment variable in a CLI |
| @@ -202,9 +202,9 @@ | ||
| 202 | 202 | // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set. |
| 203 | 203 | // We can only trust the HTTP_PROXY environment variable in a CLI |
| 204 | 204 | // process due to the fact that PHP has no reliable mechanism to |
| 205 | 205 | // get environment variables that start with "HTTP_". |
| 206 | - if (\PHP_SAPI === 'cli' && $proxy = Utils::getenv('HTTP_PROXY')) { | |
| 206 | + if (\PHP_SAPI === 'cli' && ($proxy = Utils::getenv('HTTP_PROXY'))) { | |
| 207 | 207 | $defaults['proxy']['http'] = $proxy; |
| 208 | 208 | } |
| 209 | 209 | if ($proxy = Utils::getenv('HTTPS_PROXY')) { |
| 210 | 210 | $defaults['proxy']['https'] = $proxy; |
| @@ -234,9 +234,9 @@ | ||
| 234 | 234 | * Merges default options into the array. |
| 235 | 235 | * |
| 236 | 236 | * @param array $options Options to modify by reference |
| 237 | 237 | */ |
| 238 | - private function prepareDefaults(array $options): array | |
| 238 | + private function prepareDefaults(array $options) : array | |
| 239 | 239 | { |
| 240 | 240 | $defaults = $this->config; |
| 241 | 241 | if (!empty($defaults['headers'])) { |
| 242 | 242 | // Default headers are only added if they are not present. |
| @@ -271,9 +271,9 @@ | ||
| 271 | 271 | * as-is without merging in default options. |
| 272 | 272 | * |
| 273 | 273 | * @param array $options See \GuzzleHttp\RequestOptions. |
| 274 | 274 | */ |
| 275 | - private function transfer(RequestInterface $request, array $options): PromiseInterface | |
| 275 | + private function transfer(RequestInterface $request, array $options) : PromiseInterface | |
| 276 | 276 | { |
| 277 | 277 | $request = $this->applyOptions($request, $options); |
| 278 | 278 | /** @var HandlerStack $handler */ |
| 279 | 279 | $handler = $options['handler']; |
| @@ -285,13 +285,13 @@ | ||
| 285 | 285 | } |
| 286 | 286 | /** |
| 287 | 287 | * Applies the array of request options to a request. |
| 288 | 288 | */ |
| 289 | - private function applyOptions(RequestInterface $request, array &$options): RequestInterface | |
| 289 | + private function applyOptions(RequestInterface $request, array &$options) : RequestInterface | |
| 290 | 290 | { |
| 291 | 291 | $modify = ['set_headers' => []]; |
| 292 | 292 | if (isset($options['headers'])) { |
| 293 | - if (array_keys($options['headers']) === range(0, count($options['headers']) - 1)) { | |
| 293 | + if (\array_keys($options['headers']) === \range(0, \count($options['headers']) - 1)) { | |
| 294 | 294 | throw new InvalidArgumentException('The headers array must have header name as keys.'); |
| 295 | 295 | } |
| 296 | 296 | $modify['set_headers'] = $options['headers']; |
| 297 | 297 | unset($options['headers']); |
| @@ -394,9 +394,9 @@ | ||
| 394 | 394 | } |
| 395 | 395 | /** |
| 396 | 396 | * Return an InvalidArgumentException with pre-set message. |
| 397 | 397 | */ |
| 398 | - private function invalidBody(): InvalidArgumentException | |
| 398 | + private function invalidBody() : InvalidArgumentException | |
| 399 | 399 | { |
| 400 | 400 | return new InvalidArgumentException('Passing in the "body" request ' . 'option as an array to send a request is not supported. ' . 'Please use the "form_params" request option to send a ' . 'application/x-www-form-urlencoded request, or the "multipart" ' . 'request option to send a multipart/form-data request.'); |
| 401 | 401 | } |
| 402 | 402 | } |