Completed
Pull Request — master (#421)
by Maxence
03:59
created
lib/Vendor/GuzzleHttp/BodySummarizer.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,7 @@
 block discarded – undo
3 3
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp;
4 4
 
5 5
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\MessageInterface;
6
-final class BodySummarizer implements BodySummarizerInterface
7
-{
6
+final class BodySummarizer implements BodySummarizerInterface {
8 7
     /**
9 8
      * @var int|null
10 9
      */
Please login to merge, or discard this patch.
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -5,19 +5,19 @@
 block discarded – undo
5 5
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\MessageInterface;
6 6
 final class BodySummarizer implements BodySummarizerInterface
7 7
 {
8
-    /**
9
-     * @var int|null
10
-     */
11
-    private $truncateAt;
12
-    public function __construct(?int $truncateAt = null)
13
-    {
14
-        $this->truncateAt = $truncateAt;
15
-    }
16
-    /**
17
-     * Returns a summarized message body.
18
-     */
19
-    public function summarize(MessageInterface $message) : ?string
20
-    {
21
-        return $this->truncateAt === null ? Psr7\Message::bodySummary($message) : Psr7\Message::bodySummary($message, $this->truncateAt);
22
-    }
8
+	/**
9
+	 * @var int|null
10
+	 */
11
+	private $truncateAt;
12
+	public function __construct(?int $truncateAt = null)
13
+	{
14
+		$this->truncateAt = $truncateAt;
15
+	}
16
+	/**
17
+	 * Returns a summarized message body.
18
+	 */
19
+	public function summarize(MessageInterface $message) : ?string
20
+	{
21
+		return $this->truncateAt === null ? Psr7\Message::bodySummary($message) : Psr7\Message::bodySummary($message, $this->truncateAt);
22
+	}
23 23
 }
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Utils.php 3 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
     {
23 23
         switch (\gettype($input)) {
24 24
             case 'object':
25
-                return 'object(' . \get_class($input) . ')';
25
+                return 'object('.\get_class($input).')';
26 26
             case 'array':
27
-                return 'array(' . \count($input) . ')';
27
+                return 'array('.\count($input).')';
28 28
             default:
29 29
                 \ob_start();
30 30
                 \var_dump($input);
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
             }
219 219
             // Special match if the area when prefixed with ".". Remove any
220 220
             // existing leading "." and add a new leading ".".
221
-            $area = '.' . \ltrim($area, '.');
221
+            $area = '.'.\ltrim($area, '.');
222 222
             if (\substr($host, -\strlen($area)) === $area) {
223 223
                 return \true;
224 224
             }
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
     {
245 245
         $data = \json_decode($json, $assoc, $depth, $options);
246 246
         if (\JSON_ERROR_NONE !== \json_last_error()) {
247
-            throw new InvalidArgumentException('json_decode error: ' . \json_last_error_msg());
247
+            throw new InvalidArgumentException('json_decode error: '.\json_last_error_msg());
248 248
         }
249 249
         return $data;
250 250
     }
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
     {
264 264
         $json = \json_encode($value, $options, $depth);
265 265
         if (\JSON_ERROR_NONE !== \json_last_error()) {
266
-            throw new InvalidArgumentException('json_encode error: ' . \json_last_error_msg());
266
+            throw new InvalidArgumentException('json_encode error: '.\json_last_error_msg());
267 267
         }
268 268
         /** @var string */
269 269
         return $json;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
      */
279 279
     public static function currentTime() : float
280 280
     {
281
-        return (float) \function_exists('hrtime') ? \hrtime(\true) / 1000000000.0 : \microtime(\true);
281
+        return (float)\function_exists('hrtime') ? \hrtime(\true) / 1000000000.0 : \microtime(\true);
282 282
     }
283 283
     /**
284 284
      * @throws InvalidArgumentException
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
             $asciiHost = self::idnToAsci($uri->getHost(), $options, $info);
292 292
             if ($asciiHost === \false) {
293 293
                 $errorBitSet = $info['errors'] ?? 0;
294
-                $errorConstants = \array_filter(\array_keys(\get_defined_constants()), static function (string $name) : bool {
294
+                $errorConstants = \array_filter(\array_keys(\get_defined_constants()), static function(string $name) : bool {
295 295
                     return \substr($name, 0, 11) === 'IDNA_ERROR_';
296 296
                 });
297 297
                 $errors = [];
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                 }
303 303
                 $errorMessage = 'IDN conversion failed';
304 304
                 if ($errors) {
305
-                    $errorMessage .= ' (errors: ' . \implode(', ', $errors) . ')';
305
+                    $errorMessage .= ' (errors: '.\implode(', ', $errors).')';
306 306
                 }
307 307
                 throw new InvalidArgumentException($errorMessage);
308 308
             }
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
     public static function getenv(string $name) : ?string
320 320
     {
321 321
         if (isset($_SERVER[$name])) {
322
-            return (string) $_SERVER[$name];
322
+            return (string)$_SERVER[$name];
323 323
         }
324 324
         if (\PHP_SAPI === 'cli' && ($value = \getenv($name)) !== \false && $value !== null) {
325
-            return (string) $value;
325
+            return (string)$value;
326 326
         }
327 327
         return null;
328 328
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,8 +8,7 @@
 block discarded – undo
8 8
 use OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Handler\Proxy;
9 9
 use OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Handler\StreamHandler;
10 10
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\UriInterface;
11
-final class Utils
12
-{
11
+final class Utils {
13 12
     /**
14 13
      * Debug function used to describe the provided value type and class.
15 14
      *
Please login to merge, or discard this patch.
Indentation   +313 added lines, -313 removed lines patch added patch discarded remove patch
@@ -10,147 +10,147 @@  discard block
 block discarded – undo
10 10
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\UriInterface;
11 11
 final class Utils
12 12
 {
13
-    /**
14
-     * Debug function used to describe the provided value type and class.
15
-     *
16
-     * @param mixed $input
17
-     *
18
-     * @return string Returns a string containing the type of the variable and
19
-     *                if a class is provided, the class name.
20
-     */
21
-    public static function describeType($input) : string
22
-    {
23
-        switch (\gettype($input)) {
24
-            case 'object':
25
-                return 'object(' . \get_class($input) . ')';
26
-            case 'array':
27
-                return 'array(' . \count($input) . ')';
28
-            default:
29
-                \ob_start();
30
-                \var_dump($input);
31
-                // normalize float vs double
32
-                /** @var string $varDumpContent */
33
-                $varDumpContent = \ob_get_clean();
34
-                return \str_replace('double(', 'float(', \rtrim($varDumpContent));
35
-        }
36
-    }
37
-    /**
38
-     * Parses an array of header lines into an associative array of headers.
39
-     *
40
-     * @param iterable $lines Header lines array of strings in the following
41
-     *                        format: "Name: Value"
42
-     */
43
-    public static function headersFromLines(iterable $lines) : array
44
-    {
45
-        $headers = [];
46
-        foreach ($lines as $line) {
47
-            $parts = \explode(':', $line, 2);
48
-            $headers[\trim($parts[0])][] = isset($parts[1]) ? \trim($parts[1]) : null;
49
-        }
50
-        return $headers;
51
-    }
52
-    /**
53
-     * Returns a debug stream based on the provided variable.
54
-     *
55
-     * @param mixed $value Optional value
56
-     *
57
-     * @return resource
58
-     */
59
-    public static function debugResource($value = null)
60
-    {
61
-        if (\is_resource($value)) {
62
-            return $value;
63
-        }
64
-        if (\defined('STDOUT')) {
65
-            return \STDOUT;
66
-        }
67
-        return Psr7\Utils::tryFopen('php://output', 'w');
68
-    }
69
-    /**
70
-     * Chooses and creates a default handler to use based on the environment.
71
-     *
72
-     * The returned handler is not wrapped by any default middlewares.
73
-     *
74
-     * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
75
-     *
76
-     * @throws \RuntimeException if no viable Handler is available.
77
-     */
78
-    public static function chooseHandler() : callable
79
-    {
80
-        $handler = null;
81
-        if (\defined('CURLOPT_CUSTOMREQUEST') && \function_exists('curl_version') && \version_compare(\curl_version()['version'], '7.21.2') >= 0) {
82
-            if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
83
-                $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
84
-            } elseif (\function_exists('curl_exec')) {
85
-                $handler = new CurlHandler();
86
-            } elseif (\function_exists('curl_multi_exec')) {
87
-                $handler = new CurlMultiHandler();
88
-            }
89
-        }
90
-        if (\ini_get('allow_url_fopen')) {
91
-            $handler = $handler ? Proxy::wrapStreaming($handler, new StreamHandler()) : new StreamHandler();
92
-        } elseif (!$handler) {
93
-            throw new \RuntimeException('GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler.');
94
-        }
95
-        return $handler;
96
-    }
97
-    /**
98
-     * Get the default User-Agent string to use with Guzzle.
99
-     */
100
-    public static function defaultUserAgent() : string
101
-    {
102
-        return \sprintf('GuzzleHttp/%d', ClientInterface::MAJOR_VERSION);
103
-    }
104
-    /**
105
-     * Returns the default cacert bundle for the current system.
106
-     *
107
-     * First, the openssl.cafile and curl.cainfo php.ini settings are checked.
108
-     * If those settings are not configured, then the common locations for
109
-     * bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X
110
-     * and Windows are checked. If any of these file locations are found on
111
-     * disk, they will be utilized.
112
-     *
113
-     * Note: the result of this function is cached for subsequent calls.
114
-     *
115
-     * @throws \RuntimeException if no bundle can be found.
116
-     *
117
-     * @deprecated Utils::defaultCaBundle will be removed in guzzlehttp/guzzle:8.0. This method is not needed in PHP 5.6+.
118
-     */
119
-    public static function defaultCaBundle() : string
120
-    {
121
-        static $cached = null;
122
-        static $cafiles = [
123
-            // Red Hat, CentOS, Fedora (provided by the ca-certificates package)
124
-            '/etc/pki/tls/certs/ca-bundle.crt',
125
-            // Ubuntu, Debian (provided by the ca-certificates package)
126
-            '/etc/ssl/certs/ca-certificates.crt',
127
-            // FreeBSD (provided by the ca_root_nss package)
128
-            '/usr/local/share/certs/ca-root-nss.crt',
129
-            // SLES 12 (provided by the ca-certificates package)
130
-            '/var/lib/ca-certificates/ca-bundle.pem',
131
-            // OS X provided by homebrew (using the default path)
132
-            '/usr/local/etc/openssl/cert.pem',
133
-            // Google app engine
134
-            '/etc/ca-certificates.crt',
135
-            // Windows?
136
-            'C:\\windows\\system32\\curl-ca-bundle.crt',
137
-            'C:\\windows\\curl-ca-bundle.crt',
138
-        ];
139
-        if ($cached) {
140
-            return $cached;
141
-        }
142
-        if ($ca = \ini_get('openssl.cafile')) {
143
-            return $cached = $ca;
144
-        }
145
-        if ($ca = \ini_get('curl.cainfo')) {
146
-            return $cached = $ca;
147
-        }
148
-        foreach ($cafiles as $filename) {
149
-            if (\file_exists($filename)) {
150
-                return $cached = $filename;
151
-            }
152
-        }
153
-        throw new \RuntimeException(<<<EOT
13
+	/**
14
+	 * Debug function used to describe the provided value type and class.
15
+	 *
16
+	 * @param mixed $input
17
+	 *
18
+	 * @return string Returns a string containing the type of the variable and
19
+	 *                if a class is provided, the class name.
20
+	 */
21
+	public static function describeType($input) : string
22
+	{
23
+		switch (\gettype($input)) {
24
+			case 'object':
25
+				return 'object(' . \get_class($input) . ')';
26
+			case 'array':
27
+				return 'array(' . \count($input) . ')';
28
+			default:
29
+				\ob_start();
30
+				\var_dump($input);
31
+				// normalize float vs double
32
+				/** @var string $varDumpContent */
33
+				$varDumpContent = \ob_get_clean();
34
+				return \str_replace('double(', 'float(', \rtrim($varDumpContent));
35
+		}
36
+	}
37
+	/**
38
+	 * Parses an array of header lines into an associative array of headers.
39
+	 *
40
+	 * @param iterable $lines Header lines array of strings in the following
41
+	 *                        format: "Name: Value"
42
+	 */
43
+	public static function headersFromLines(iterable $lines) : array
44
+	{
45
+		$headers = [];
46
+		foreach ($lines as $line) {
47
+			$parts = \explode(':', $line, 2);
48
+			$headers[\trim($parts[0])][] = isset($parts[1]) ? \trim($parts[1]) : null;
49
+		}
50
+		return $headers;
51
+	}
52
+	/**
53
+	 * Returns a debug stream based on the provided variable.
54
+	 *
55
+	 * @param mixed $value Optional value
56
+	 *
57
+	 * @return resource
58
+	 */
59
+	public static function debugResource($value = null)
60
+	{
61
+		if (\is_resource($value)) {
62
+			return $value;
63
+		}
64
+		if (\defined('STDOUT')) {
65
+			return \STDOUT;
66
+		}
67
+		return Psr7\Utils::tryFopen('php://output', 'w');
68
+	}
69
+	/**
70
+	 * Chooses and creates a default handler to use based on the environment.
71
+	 *
72
+	 * The returned handler is not wrapped by any default middlewares.
73
+	 *
74
+	 * @return callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the best handler for the given system.
75
+	 *
76
+	 * @throws \RuntimeException if no viable Handler is available.
77
+	 */
78
+	public static function chooseHandler() : callable
79
+	{
80
+		$handler = null;
81
+		if (\defined('CURLOPT_CUSTOMREQUEST') && \function_exists('curl_version') && \version_compare(\curl_version()['version'], '7.21.2') >= 0) {
82
+			if (\function_exists('curl_multi_exec') && \function_exists('curl_exec')) {
83
+				$handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
84
+			} elseif (\function_exists('curl_exec')) {
85
+				$handler = new CurlHandler();
86
+			} elseif (\function_exists('curl_multi_exec')) {
87
+				$handler = new CurlMultiHandler();
88
+			}
89
+		}
90
+		if (\ini_get('allow_url_fopen')) {
91
+			$handler = $handler ? Proxy::wrapStreaming($handler, new StreamHandler()) : new StreamHandler();
92
+		} elseif (!$handler) {
93
+			throw new \RuntimeException('GuzzleHttp requires cURL, the allow_url_fopen ini setting, or a custom HTTP handler.');
94
+		}
95
+		return $handler;
96
+	}
97
+	/**
98
+	 * Get the default User-Agent string to use with Guzzle.
99
+	 */
100
+	public static function defaultUserAgent() : string
101
+	{
102
+		return \sprintf('GuzzleHttp/%d', ClientInterface::MAJOR_VERSION);
103
+	}
104
+	/**
105
+	 * Returns the default cacert bundle for the current system.
106
+	 *
107
+	 * First, the openssl.cafile and curl.cainfo php.ini settings are checked.
108
+	 * If those settings are not configured, then the common locations for
109
+	 * bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X
110
+	 * and Windows are checked. If any of these file locations are found on
111
+	 * disk, they will be utilized.
112
+	 *
113
+	 * Note: the result of this function is cached for subsequent calls.
114
+	 *
115
+	 * @throws \RuntimeException if no bundle can be found.
116
+	 *
117
+	 * @deprecated Utils::defaultCaBundle will be removed in guzzlehttp/guzzle:8.0. This method is not needed in PHP 5.6+.
118
+	 */
119
+	public static function defaultCaBundle() : string
120
+	{
121
+		static $cached = null;
122
+		static $cafiles = [
123
+			// Red Hat, CentOS, Fedora (provided by the ca-certificates package)
124
+			'/etc/pki/tls/certs/ca-bundle.crt',
125
+			// Ubuntu, Debian (provided by the ca-certificates package)
126
+			'/etc/ssl/certs/ca-certificates.crt',
127
+			// FreeBSD (provided by the ca_root_nss package)
128
+			'/usr/local/share/certs/ca-root-nss.crt',
129
+			// SLES 12 (provided by the ca-certificates package)
130
+			'/var/lib/ca-certificates/ca-bundle.pem',
131
+			// OS X provided by homebrew (using the default path)
132
+			'/usr/local/etc/openssl/cert.pem',
133
+			// Google app engine
134
+			'/etc/ca-certificates.crt',
135
+			// Windows?
136
+			'C:\\windows\\system32\\curl-ca-bundle.crt',
137
+			'C:\\windows\\curl-ca-bundle.crt',
138
+		];
139
+		if ($cached) {
140
+			return $cached;
141
+		}
142
+		if ($ca = \ini_get('openssl.cafile')) {
143
+			return $cached = $ca;
144
+		}
145
+		if ($ca = \ini_get('curl.cainfo')) {
146
+			return $cached = $ca;
147
+		}
148
+		foreach ($cafiles as $filename) {
149
+			if (\file_exists($filename)) {
150
+				return $cached = $filename;
151
+			}
152
+		}
153
+		throw new \RuntimeException(<<<EOT
154 154
 No system CA bundle could be found in any of the the common system locations.
155 155
 PHP versions earlier than 5.6 are not properly configured to use the system's
156 156
 CA bundle by default. In order to verify peer certificates, you will need to
@@ -164,176 +164,176 @@  discard block
 block discarded – undo
164 164
 https://curl.haxx.se/docs/sslcerts.html for more information.
165 165
 EOT
166 166
 );
167
-    }
168
-    /**
169
-     * Creates an associative array of lowercase header names to the actual
170
-     * header casing.
171
-     */
172
-    public static function normalizeHeaderKeys(array $headers) : array
173
-    {
174
-        $result = [];
175
-        foreach (\array_keys($headers) as $key) {
176
-            $result[\strtolower($key)] = $key;
177
-        }
178
-        return $result;
179
-    }
180
-    /**
181
-     * Returns true if the provided host matches any of the no proxy areas.
182
-     *
183
-     * This method will strip a port from the host if it is present. Each pattern
184
-     * can be matched with an exact match (e.g., "foo.com" == "foo.com") or a
185
-     * partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" ==
186
-     * "baz.foo.com", but ".foo.com" != "foo.com").
187
-     *
188
-     * Areas are matched in the following cases:
189
-     * 1. "*" (without quotes) always matches any hosts.
190
-     * 2. An exact match.
191
-     * 3. The area starts with "." and the area is the last part of the host. e.g.
192
-     *    '.mit.edu' will match any host that ends with '.mit.edu'.
193
-     *
194
-     * @param string   $host         Host to check against the patterns.
195
-     * @param string[] $noProxyArray An array of host patterns.
196
-     *
197
-     * @throws InvalidArgumentException
198
-     */
199
-    public static function isHostInNoProxy(string $host, array $noProxyArray) : bool
200
-    {
201
-        if (\strlen($host) === 0) {
202
-            throw new InvalidArgumentException('Empty host provided');
203
-        }
204
-        // Strip port if present.
205
-        [$host] = \explode(':', $host, 2);
206
-        foreach ($noProxyArray as $area) {
207
-            // Always match on wildcards.
208
-            if ($area === '*') {
209
-                return \true;
210
-            }
211
-            if (empty($area)) {
212
-                // Don't match on empty values.
213
-                continue;
214
-            }
215
-            if ($area === $host) {
216
-                // Exact matches.
217
-                return \true;
218
-            }
219
-            // Special match if the area when prefixed with ".". Remove any
220
-            // existing leading "." and add a new leading ".".
221
-            $area = '.' . \ltrim($area, '.');
222
-            if (\substr($host, -\strlen($area)) === $area) {
223
-                return \true;
224
-            }
225
-        }
226
-        return \false;
227
-    }
228
-    /**
229
-     * Wrapper for json_decode that throws when an error occurs.
230
-     *
231
-     * @param string $json    JSON data to parse
232
-     * @param bool   $assoc   When true, returned objects will be converted
233
-     *                        into associative arrays.
234
-     * @param int    $depth   User specified recursion depth.
235
-     * @param int    $options Bitmask of JSON decode options.
236
-     *
237
-     * @return object|array|string|int|float|bool|null
238
-     *
239
-     * @throws InvalidArgumentException if the JSON cannot be decoded.
240
-     *
241
-     * @see https://www.php.net/manual/en/function.json-decode.php
242
-     */
243
-    public static function jsonDecode(string $json, bool $assoc = \false, int $depth = 512, int $options = 0)
244
-    {
245
-        $data = \json_decode($json, $assoc, $depth, $options);
246
-        if (\JSON_ERROR_NONE !== \json_last_error()) {
247
-            throw new InvalidArgumentException('json_decode error: ' . \json_last_error_msg());
248
-        }
249
-        return $data;
250
-    }
251
-    /**
252
-     * Wrapper for JSON encoding that throws when an error occurs.
253
-     *
254
-     * @param mixed $value   The value being encoded
255
-     * @param int   $options JSON encode option bitmask
256
-     * @param int   $depth   Set the maximum depth. Must be greater than zero.
257
-     *
258
-     * @throws InvalidArgumentException if the JSON cannot be encoded.
259
-     *
260
-     * @see https://www.php.net/manual/en/function.json-encode.php
261
-     */
262
-    public static function jsonEncode($value, int $options = 0, int $depth = 512) : string
263
-    {
264
-        $json = \json_encode($value, $options, $depth);
265
-        if (\JSON_ERROR_NONE !== \json_last_error()) {
266
-            throw new InvalidArgumentException('json_encode error: ' . \json_last_error_msg());
267
-        }
268
-        /** @var string */
269
-        return $json;
270
-    }
271
-    /**
272
-     * Wrapper for the hrtime() or microtime() functions
273
-     * (depending on the PHP version, one of the two is used)
274
-     *
275
-     * @return float UNIX timestamp
276
-     *
277
-     * @internal
278
-     */
279
-    public static function currentTime() : float
280
-    {
281
-        return (float) \function_exists('hrtime') ? \hrtime(\true) / 1000000000.0 : \microtime(\true);
282
-    }
283
-    /**
284
-     * @throws InvalidArgumentException
285
-     *
286
-     * @internal
287
-     */
288
-    public static function idnUriConvert(UriInterface $uri, int $options = 0) : UriInterface
289
-    {
290
-        if ($uri->getHost()) {
291
-            $asciiHost = self::idnToAsci($uri->getHost(), $options, $info);
292
-            if ($asciiHost === \false) {
293
-                $errorBitSet = $info['errors'] ?? 0;
294
-                $errorConstants = \array_filter(\array_keys(\get_defined_constants()), static function (string $name) : bool {
295
-                    return \substr($name, 0, 11) === 'IDNA_ERROR_';
296
-                });
297
-                $errors = [];
298
-                foreach ($errorConstants as $errorConstant) {
299
-                    if ($errorBitSet & \constant($errorConstant)) {
300
-                        $errors[] = $errorConstant;
301
-                    }
302
-                }
303
-                $errorMessage = 'IDN conversion failed';
304
-                if ($errors) {
305
-                    $errorMessage .= ' (errors: ' . \implode(', ', $errors) . ')';
306
-                }
307
-                throw new InvalidArgumentException($errorMessage);
308
-            }
309
-            if ($uri->getHost() !== $asciiHost) {
310
-                // Replace URI only if the ASCII version is different
311
-                $uri = $uri->withHost($asciiHost);
312
-            }
313
-        }
314
-        return $uri;
315
-    }
316
-    /**
317
-     * @internal
318
-     */
319
-    public static function getenv(string $name) : ?string
320
-    {
321
-        if (isset($_SERVER[$name])) {
322
-            return (string) $_SERVER[$name];
323
-        }
324
-        if (\PHP_SAPI === 'cli' && ($value = \getenv($name)) !== \false && $value !== null) {
325
-            return (string) $value;
326
-        }
327
-        return null;
328
-    }
329
-    /**
330
-     * @return string|false
331
-     */
332
-    private static function idnToAsci(string $domain, int $options, ?array &$info = [])
333
-    {
334
-        if (\function_exists('idn_to_ascii') && \defined('INTL_IDNA_VARIANT_UTS46')) {
335
-            return \idn_to_ascii($domain, $options, \INTL_IDNA_VARIANT_UTS46, $info);
336
-        }
337
-        throw new \Error('ext-idn or symfony/polyfill-intl-idn not loaded or too old');
338
-    }
167
+	}
168
+	/**
169
+	 * Creates an associative array of lowercase header names to the actual
170
+	 * header casing.
171
+	 */
172
+	public static function normalizeHeaderKeys(array $headers) : array
173
+	{
174
+		$result = [];
175
+		foreach (\array_keys($headers) as $key) {
176
+			$result[\strtolower($key)] = $key;
177
+		}
178
+		return $result;
179
+	}
180
+	/**
181
+	 * Returns true if the provided host matches any of the no proxy areas.
182
+	 *
183
+	 * This method will strip a port from the host if it is present. Each pattern
184
+	 * can be matched with an exact match (e.g., "foo.com" == "foo.com") or a
185
+	 * partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" ==
186
+	 * "baz.foo.com", but ".foo.com" != "foo.com").
187
+	 *
188
+	 * Areas are matched in the following cases:
189
+	 * 1. "*" (without quotes) always matches any hosts.
190
+	 * 2. An exact match.
191
+	 * 3. The area starts with "." and the area is the last part of the host. e.g.
192
+	 *    '.mit.edu' will match any host that ends with '.mit.edu'.
193
+	 *
194
+	 * @param string   $host         Host to check against the patterns.
195
+	 * @param string[] $noProxyArray An array of host patterns.
196
+	 *
197
+	 * @throws InvalidArgumentException
198
+	 */
199
+	public static function isHostInNoProxy(string $host, array $noProxyArray) : bool
200
+	{
201
+		if (\strlen($host) === 0) {
202
+			throw new InvalidArgumentException('Empty host provided');
203
+		}
204
+		// Strip port if present.
205
+		[$host] = \explode(':', $host, 2);
206
+		foreach ($noProxyArray as $area) {
207
+			// Always match on wildcards.
208
+			if ($area === '*') {
209
+				return \true;
210
+			}
211
+			if (empty($area)) {
212
+				// Don't match on empty values.
213
+				continue;
214
+			}
215
+			if ($area === $host) {
216
+				// Exact matches.
217
+				return \true;
218
+			}
219
+			// Special match if the area when prefixed with ".". Remove any
220
+			// existing leading "." and add a new leading ".".
221
+			$area = '.' . \ltrim($area, '.');
222
+			if (\substr($host, -\strlen($area)) === $area) {
223
+				return \true;
224
+			}
225
+		}
226
+		return \false;
227
+	}
228
+	/**
229
+	 * Wrapper for json_decode that throws when an error occurs.
230
+	 *
231
+	 * @param string $json    JSON data to parse
232
+	 * @param bool   $assoc   When true, returned objects will be converted
233
+	 *                        into associative arrays.
234
+	 * @param int    $depth   User specified recursion depth.
235
+	 * @param int    $options Bitmask of JSON decode options.
236
+	 *
237
+	 * @return object|array|string|int|float|bool|null
238
+	 *
239
+	 * @throws InvalidArgumentException if the JSON cannot be decoded.
240
+	 *
241
+	 * @see https://www.php.net/manual/en/function.json-decode.php
242
+	 */
243
+	public static function jsonDecode(string $json, bool $assoc = \false, int $depth = 512, int $options = 0)
244
+	{
245
+		$data = \json_decode($json, $assoc, $depth, $options);
246
+		if (\JSON_ERROR_NONE !== \json_last_error()) {
247
+			throw new InvalidArgumentException('json_decode error: ' . \json_last_error_msg());
248
+		}
249
+		return $data;
250
+	}
251
+	/**
252
+	 * Wrapper for JSON encoding that throws when an error occurs.
253
+	 *
254
+	 * @param mixed $value   The value being encoded
255
+	 * @param int   $options JSON encode option bitmask
256
+	 * @param int   $depth   Set the maximum depth. Must be greater than zero.
257
+	 *
258
+	 * @throws InvalidArgumentException if the JSON cannot be encoded.
259
+	 *
260
+	 * @see https://www.php.net/manual/en/function.json-encode.php
261
+	 */
262
+	public static function jsonEncode($value, int $options = 0, int $depth = 512) : string
263
+	{
264
+		$json = \json_encode($value, $options, $depth);
265
+		if (\JSON_ERROR_NONE !== \json_last_error()) {
266
+			throw new InvalidArgumentException('json_encode error: ' . \json_last_error_msg());
267
+		}
268
+		/** @var string */
269
+		return $json;
270
+	}
271
+	/**
272
+	 * Wrapper for the hrtime() or microtime() functions
273
+	 * (depending on the PHP version, one of the two is used)
274
+	 *
275
+	 * @return float UNIX timestamp
276
+	 *
277
+	 * @internal
278
+	 */
279
+	public static function currentTime() : float
280
+	{
281
+		return (float) \function_exists('hrtime') ? \hrtime(\true) / 1000000000.0 : \microtime(\true);
282
+	}
283
+	/**
284
+	 * @throws InvalidArgumentException
285
+	 *
286
+	 * @internal
287
+	 */
288
+	public static function idnUriConvert(UriInterface $uri, int $options = 0) : UriInterface
289
+	{
290
+		if ($uri->getHost()) {
291
+			$asciiHost = self::idnToAsci($uri->getHost(), $options, $info);
292
+			if ($asciiHost === \false) {
293
+				$errorBitSet = $info['errors'] ?? 0;
294
+				$errorConstants = \array_filter(\array_keys(\get_defined_constants()), static function (string $name) : bool {
295
+					return \substr($name, 0, 11) === 'IDNA_ERROR_';
296
+				});
297
+				$errors = [];
298
+				foreach ($errorConstants as $errorConstant) {
299
+					if ($errorBitSet & \constant($errorConstant)) {
300
+						$errors[] = $errorConstant;
301
+					}
302
+				}
303
+				$errorMessage = 'IDN conversion failed';
304
+				if ($errors) {
305
+					$errorMessage .= ' (errors: ' . \implode(', ', $errors) . ')';
306
+				}
307
+				throw new InvalidArgumentException($errorMessage);
308
+			}
309
+			if ($uri->getHost() !== $asciiHost) {
310
+				// Replace URI only if the ASCII version is different
311
+				$uri = $uri->withHost($asciiHost);
312
+			}
313
+		}
314
+		return $uri;
315
+	}
316
+	/**
317
+	 * @internal
318
+	 */
319
+	public static function getenv(string $name) : ?string
320
+	{
321
+		if (isset($_SERVER[$name])) {
322
+			return (string) $_SERVER[$name];
323
+		}
324
+		if (\PHP_SAPI === 'cli' && ($value = \getenv($name)) !== \false && $value !== null) {
325
+			return (string) $value;
326
+		}
327
+		return null;
328
+	}
329
+	/**
330
+	 * @return string|false
331
+	 */
332
+	private static function idnToAsci(string $domain, int $options, ?array &$info = [])
333
+	{
334
+		if (\function_exists('idn_to_ascii') && \defined('INTL_IDNA_VARIANT_UTS46')) {
335
+			return \idn_to_ascii($domain, $options, \INTL_IDNA_VARIANT_UTS46, $info);
336
+		}
337
+		throw new \Error('ext-idn or symfony/polyfill-intl-idn not loaded or too old');
338
+	}
339 339
 }
Please login to merge, or discard this patch.
lib/Vendor/Http/Discovery/Psr17Factory.php 2 patches
Indentation   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -40,202 +40,202 @@
 block discarded – undo
40 40
  */
41 41
 class Psr17Factory implements RequestFactoryInterface, ResponseFactoryInterface, ServerRequestFactoryInterface, StreamFactoryInterface, UploadedFileFactoryInterface, UriFactoryInterface
42 42
 {
43
-    private $requestFactory;
44
-    private $responseFactory;
45
-    private $serverRequestFactory;
46
-    private $streamFactory;
47
-    private $uploadedFileFactory;
48
-    private $uriFactory;
49
-    public function __construct(?RequestFactoryInterface $requestFactory = null, ?ResponseFactoryInterface $responseFactory = null, ?ServerRequestFactoryInterface $serverRequestFactory = null, ?StreamFactoryInterface $streamFactory = null, ?UploadedFileFactoryInterface $uploadedFileFactory = null, ?UriFactoryInterface $uriFactory = null)
50
-    {
51
-        $this->requestFactory = $requestFactory;
52
-        $this->responseFactory = $responseFactory;
53
-        $this->serverRequestFactory = $serverRequestFactory;
54
-        $this->streamFactory = $streamFactory;
55
-        $this->uploadedFileFactory = $uploadedFileFactory;
56
-        $this->uriFactory = $uriFactory;
57
-        $this->setFactory($requestFactory);
58
-        $this->setFactory($responseFactory);
59
-        $this->setFactory($serverRequestFactory);
60
-        $this->setFactory($streamFactory);
61
-        $this->setFactory($uploadedFileFactory);
62
-        $this->setFactory($uriFactory);
63
-    }
64
-    /**
65
-     * @param UriInterface|string $uri
66
-     */
67
-    public function createRequest(string $method, $uri) : RequestInterface
68
-    {
69
-        $factory = $this->requestFactory ?? $this->setFactory(Psr17FactoryDiscovery::findRequestFactory());
70
-        return $factory->createRequest(...\func_get_args());
71
-    }
72
-    public function createResponse(int $code = 200, string $reasonPhrase = '') : ResponseInterface
73
-    {
74
-        $factory = $this->responseFactory ?? $this->setFactory(Psr17FactoryDiscovery::findResponseFactory());
75
-        return $factory->createResponse(...\func_get_args());
76
-    }
77
-    /**
78
-     * @param UriInterface|string $uri
79
-     */
80
-    public function createServerRequest(string $method, $uri, array $serverParams = []) : ServerRequestInterface
81
-    {
82
-        $factory = $this->serverRequestFactory ?? $this->setFactory(Psr17FactoryDiscovery::findServerRequestFactory());
83
-        return $factory->createServerRequest(...\func_get_args());
84
-    }
85
-    public function createServerRequestFromGlobals(?array $server = null, ?array $get = null, ?array $post = null, ?array $cookie = null, ?array $files = null, ?StreamInterface $body = null) : ServerRequestInterface
86
-    {
87
-        $server = $server ?? $_SERVER;
88
-        $request = $this->createServerRequest($server['REQUEST_METHOD'] ?? 'GET', $this->createUriFromGlobals($server), $server);
89
-        return $this->buildServerRequestFromGlobals($request, $server, $files ?? $_FILES)->withQueryParams($get ?? $_GET)->withParsedBody($post ?? $_POST)->withCookieParams($cookie ?? $_COOKIE)->withBody($body ?? $this->createStreamFromFile('php://input', 'r+'));
90
-    }
91
-    public function createStream(string $content = '') : StreamInterface
92
-    {
93
-        $factory = $this->streamFactory ?? $this->setFactory(Psr17FactoryDiscovery::findStreamFactory());
94
-        return $factory->createStream($content);
95
-    }
96
-    public function createStreamFromFile(string $filename, string $mode = 'r') : StreamInterface
97
-    {
98
-        $factory = $this->streamFactory ?? $this->setFactory(Psr17FactoryDiscovery::findStreamFactory());
99
-        return $factory->createStreamFromFile($filename, $mode);
100
-    }
101
-    /**
102
-     * @param resource $resource
103
-     */
104
-    public function createStreamFromResource($resource) : StreamInterface
105
-    {
106
-        $factory = $this->streamFactory ?? $this->setFactory(Psr17FactoryDiscovery::findStreamFactory());
107
-        return $factory->createStreamFromResource($resource);
108
-    }
109
-    public function createUploadedFile(StreamInterface $stream, ?int $size = null, int $error = \UPLOAD_ERR_OK, ?string $clientFilename = null, ?string $clientMediaType = null) : UploadedFileInterface
110
-    {
111
-        $factory = $this->uploadedFileFactory ?? $this->setFactory(Psr17FactoryDiscovery::findUploadedFileFactory());
112
-        return $factory->createUploadedFile(...\func_get_args());
113
-    }
114
-    public function createUri(string $uri = '') : UriInterface
115
-    {
116
-        $factory = $this->uriFactory ?? $this->setFactory(Psr17FactoryDiscovery::findUriFactory());
117
-        return $factory->createUri(...\func_get_args());
118
-    }
119
-    public function createUriFromGlobals(?array $server = null) : UriInterface
120
-    {
121
-        return $this->buildUriFromGlobals($this->createUri(''), $server ?? $_SERVER);
122
-    }
123
-    private function setFactory($factory)
124
-    {
125
-        if (!$this->requestFactory && $factory instanceof RequestFactoryInterface) {
126
-            $this->requestFactory = $factory;
127
-        }
128
-        if (!$this->responseFactory && $factory instanceof ResponseFactoryInterface) {
129
-            $this->responseFactory = $factory;
130
-        }
131
-        if (!$this->serverRequestFactory && $factory instanceof ServerRequestFactoryInterface) {
132
-            $this->serverRequestFactory = $factory;
133
-        }
134
-        if (!$this->streamFactory && $factory instanceof StreamFactoryInterface) {
135
-            $this->streamFactory = $factory;
136
-        }
137
-        if (!$this->uploadedFileFactory && $factory instanceof UploadedFileFactoryInterface) {
138
-            $this->uploadedFileFactory = $factory;
139
-        }
140
-        if (!$this->uriFactory && $factory instanceof UriFactoryInterface) {
141
-            $this->uriFactory = $factory;
142
-        }
143
-        return $factory;
144
-    }
145
-    private function buildServerRequestFromGlobals(ServerRequestInterface $request, array $server, array $files) : ServerRequestInterface
146
-    {
147
-        $request = $request->withProtocolVersion(isset($server['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $server['SERVER_PROTOCOL']) : '1.1')->withUploadedFiles($this->normalizeFiles($files));
148
-        $headers = [];
149
-        foreach ($server as $k => $v) {
150
-            if (0 === \strpos($k, 'HTTP_')) {
151
-                $k = \substr($k, 5);
152
-            } elseif (!\in_array($k, ['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'], \true)) {
153
-                continue;
154
-            }
155
-            $k = \str_replace(' ', '-', \ucwords(\strtolower(\str_replace('_', ' ', $k))));
156
-            $headers[$k] = $v;
157
-        }
158
-        if (!isset($headers['Authorization'])) {
159
-            if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
160
-                $headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
161
-            } elseif (isset($_SERVER['PHP_AUTH_USER'])) {
162
-                $headers['Authorization'] = 'Basic ' . \base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . ($_SERVER['PHP_AUTH_PW'] ?? ''));
163
-            } elseif (isset($_SERVER['PHP_AUTH_DIGEST'])) {
164
-                $headers['Authorization'] = $_SERVER['PHP_AUTH_DIGEST'];
165
-            }
166
-        }
167
-        foreach ($headers as $k => $v) {
168
-            try {
169
-                $request = $request->withHeader($k, $v);
170
-            } catch (\InvalidArgumentException $e) {
171
-                // ignore invalid headers
172
-            }
173
-        }
174
-        return $request;
175
-    }
176
-    private function buildUriFromGlobals(UriInterface $uri, array $server) : UriInterface
177
-    {
178
-        $uri = $uri->withScheme(!empty($server['HTTPS']) && 'off' !== \strtolower($server['HTTPS']) ? 'https' : 'http');
179
-        $hasPort = \false;
180
-        if (isset($server['HTTP_HOST'])) {
181
-            $parts = \parse_url('http://' . $server['HTTP_HOST']);
182
-            $uri = $uri->withHost($parts['host'] ?? 'localhost');
183
-            if ($parts['port'] ?? \false) {
184
-                $hasPort = \true;
185
-                $uri = $uri->withPort($parts['port']);
186
-            }
187
-        } else {
188
-            $uri = $uri->withHost($server['SERVER_NAME'] ?? $server['SERVER_ADDR'] ?? 'localhost');
189
-        }
190
-        if (!$hasPort && isset($server['SERVER_PORT'])) {
191
-            $uri = $uri->withPort($server['SERVER_PORT']);
192
-        }
193
-        $hasQuery = \false;
194
-        if (isset($server['REQUEST_URI'])) {
195
-            $requestUriParts = \explode('?', $server['REQUEST_URI'], 2);
196
-            $uri = $uri->withPath($requestUriParts[0]);
197
-            if (isset($requestUriParts[1])) {
198
-                $hasQuery = \true;
199
-                $uri = $uri->withQuery($requestUriParts[1]);
200
-            }
201
-        }
202
-        if (!$hasQuery && isset($server['QUERY_STRING'])) {
203
-            $uri = $uri->withQuery($server['QUERY_STRING']);
204
-        }
205
-        return $uri;
206
-    }
207
-    private function normalizeFiles(array $files) : array
208
-    {
209
-        foreach ($files as $k => $v) {
210
-            if ($v instanceof UploadedFileInterface) {
211
-                continue;
212
-            }
213
-            if (!\is_array($v)) {
214
-                unset($files[$k]);
215
-            } elseif (!isset($v['tmp_name'])) {
216
-                $files[$k] = $this->normalizeFiles($v);
217
-            } else {
218
-                $files[$k] = $this->createUploadedFileFromSpec($v);
219
-            }
220
-        }
221
-        return $files;
222
-    }
223
-    /**
224
-     * Create and return an UploadedFile instance from a $_FILES specification.
225
-     *
226
-     * @param array $value $_FILES struct
227
-     *
228
-     * @return UploadedFileInterface|UploadedFileInterface[]
229
-     */
230
-    private function createUploadedFileFromSpec(array $value)
231
-    {
232
-        if (!\is_array($tmpName = $value['tmp_name'])) {
233
-            $file = \is_file($tmpName) ? $this->createStreamFromFile($tmpName, 'r') : $this->createStream();
234
-            return $this->createUploadedFile($file, $value['size'], $value['error'], $value['name'], $value['type']);
235
-        }
236
-        foreach ($tmpName as $k => $v) {
237
-            $tmpName[$k] = $this->createUploadedFileFromSpec(['tmp_name' => $v, 'size' => $value['size'][$k] ?? null, 'error' => $value['error'][$k] ?? null, 'name' => $value['name'][$k] ?? null, 'type' => $value['type'][$k] ?? null]);
238
-        }
239
-        return $tmpName;
240
-    }
43
+	private $requestFactory;
44
+	private $responseFactory;
45
+	private $serverRequestFactory;
46
+	private $streamFactory;
47
+	private $uploadedFileFactory;
48
+	private $uriFactory;
49
+	public function __construct(?RequestFactoryInterface $requestFactory = null, ?ResponseFactoryInterface $responseFactory = null, ?ServerRequestFactoryInterface $serverRequestFactory = null, ?StreamFactoryInterface $streamFactory = null, ?UploadedFileFactoryInterface $uploadedFileFactory = null, ?UriFactoryInterface $uriFactory = null)
50
+	{
51
+		$this->requestFactory = $requestFactory;
52
+		$this->responseFactory = $responseFactory;
53
+		$this->serverRequestFactory = $serverRequestFactory;
54
+		$this->streamFactory = $streamFactory;
55
+		$this->uploadedFileFactory = $uploadedFileFactory;
56
+		$this->uriFactory = $uriFactory;
57
+		$this->setFactory($requestFactory);
58
+		$this->setFactory($responseFactory);
59
+		$this->setFactory($serverRequestFactory);
60
+		$this->setFactory($streamFactory);
61
+		$this->setFactory($uploadedFileFactory);
62
+		$this->setFactory($uriFactory);
63
+	}
64
+	/**
65
+	 * @param UriInterface|string $uri
66
+	 */
67
+	public function createRequest(string $method, $uri) : RequestInterface
68
+	{
69
+		$factory = $this->requestFactory ?? $this->setFactory(Psr17FactoryDiscovery::findRequestFactory());
70
+		return $factory->createRequest(...\func_get_args());
71
+	}
72
+	public function createResponse(int $code = 200, string $reasonPhrase = '') : ResponseInterface
73
+	{
74
+		$factory = $this->responseFactory ?? $this->setFactory(Psr17FactoryDiscovery::findResponseFactory());
75
+		return $factory->createResponse(...\func_get_args());
76
+	}
77
+	/**
78
+	 * @param UriInterface|string $uri
79
+	 */
80
+	public function createServerRequest(string $method, $uri, array $serverParams = []) : ServerRequestInterface
81
+	{
82
+		$factory = $this->serverRequestFactory ?? $this->setFactory(Psr17FactoryDiscovery::findServerRequestFactory());
83
+		return $factory->createServerRequest(...\func_get_args());
84
+	}
85
+	public function createServerRequestFromGlobals(?array $server = null, ?array $get = null, ?array $post = null, ?array $cookie = null, ?array $files = null, ?StreamInterface $body = null) : ServerRequestInterface
86
+	{
87
+		$server = $server ?? $_SERVER;
88
+		$request = $this->createServerRequest($server['REQUEST_METHOD'] ?? 'GET', $this->createUriFromGlobals($server), $server);
89
+		return $this->buildServerRequestFromGlobals($request, $server, $files ?? $_FILES)->withQueryParams($get ?? $_GET)->withParsedBody($post ?? $_POST)->withCookieParams($cookie ?? $_COOKIE)->withBody($body ?? $this->createStreamFromFile('php://input', 'r+'));
90
+	}
91
+	public function createStream(string $content = '') : StreamInterface
92
+	{
93
+		$factory = $this->streamFactory ?? $this->setFactory(Psr17FactoryDiscovery::findStreamFactory());
94
+		return $factory->createStream($content);
95
+	}
96
+	public function createStreamFromFile(string $filename, string $mode = 'r') : StreamInterface
97
+	{
98
+		$factory = $this->streamFactory ?? $this->setFactory(Psr17FactoryDiscovery::findStreamFactory());
99
+		return $factory->createStreamFromFile($filename, $mode);
100
+	}
101
+	/**
102
+	 * @param resource $resource
103
+	 */
104
+	public function createStreamFromResource($resource) : StreamInterface
105
+	{
106
+		$factory = $this->streamFactory ?? $this->setFactory(Psr17FactoryDiscovery::findStreamFactory());
107
+		return $factory->createStreamFromResource($resource);
108
+	}
109
+	public function createUploadedFile(StreamInterface $stream, ?int $size = null, int $error = \UPLOAD_ERR_OK, ?string $clientFilename = null, ?string $clientMediaType = null) : UploadedFileInterface
110
+	{
111
+		$factory = $this->uploadedFileFactory ?? $this->setFactory(Psr17FactoryDiscovery::findUploadedFileFactory());
112
+		return $factory->createUploadedFile(...\func_get_args());
113
+	}
114
+	public function createUri(string $uri = '') : UriInterface
115
+	{
116
+		$factory = $this->uriFactory ?? $this->setFactory(Psr17FactoryDiscovery::findUriFactory());
117
+		return $factory->createUri(...\func_get_args());
118
+	}
119
+	public function createUriFromGlobals(?array $server = null) : UriInterface
120
+	{
121
+		return $this->buildUriFromGlobals($this->createUri(''), $server ?? $_SERVER);
122
+	}
123
+	private function setFactory($factory)
124
+	{
125
+		if (!$this->requestFactory && $factory instanceof RequestFactoryInterface) {
126
+			$this->requestFactory = $factory;
127
+		}
128
+		if (!$this->responseFactory && $factory instanceof ResponseFactoryInterface) {
129
+			$this->responseFactory = $factory;
130
+		}
131
+		if (!$this->serverRequestFactory && $factory instanceof ServerRequestFactoryInterface) {
132
+			$this->serverRequestFactory = $factory;
133
+		}
134
+		if (!$this->streamFactory && $factory instanceof StreamFactoryInterface) {
135
+			$this->streamFactory = $factory;
136
+		}
137
+		if (!$this->uploadedFileFactory && $factory instanceof UploadedFileFactoryInterface) {
138
+			$this->uploadedFileFactory = $factory;
139
+		}
140
+		if (!$this->uriFactory && $factory instanceof UriFactoryInterface) {
141
+			$this->uriFactory = $factory;
142
+		}
143
+		return $factory;
144
+	}
145
+	private function buildServerRequestFromGlobals(ServerRequestInterface $request, array $server, array $files) : ServerRequestInterface
146
+	{
147
+		$request = $request->withProtocolVersion(isset($server['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $server['SERVER_PROTOCOL']) : '1.1')->withUploadedFiles($this->normalizeFiles($files));
148
+		$headers = [];
149
+		foreach ($server as $k => $v) {
150
+			if (0 === \strpos($k, 'HTTP_')) {
151
+				$k = \substr($k, 5);
152
+			} elseif (!\in_array($k, ['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'], \true)) {
153
+				continue;
154
+			}
155
+			$k = \str_replace(' ', '-', \ucwords(\strtolower(\str_replace('_', ' ', $k))));
156
+			$headers[$k] = $v;
157
+		}
158
+		if (!isset($headers['Authorization'])) {
159
+			if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
160
+				$headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
161
+			} elseif (isset($_SERVER['PHP_AUTH_USER'])) {
162
+				$headers['Authorization'] = 'Basic ' . \base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . ($_SERVER['PHP_AUTH_PW'] ?? ''));
163
+			} elseif (isset($_SERVER['PHP_AUTH_DIGEST'])) {
164
+				$headers['Authorization'] = $_SERVER['PHP_AUTH_DIGEST'];
165
+			}
166
+		}
167
+		foreach ($headers as $k => $v) {
168
+			try {
169
+				$request = $request->withHeader($k, $v);
170
+			} catch (\InvalidArgumentException $e) {
171
+				// ignore invalid headers
172
+			}
173
+		}
174
+		return $request;
175
+	}
176
+	private function buildUriFromGlobals(UriInterface $uri, array $server) : UriInterface
177
+	{
178
+		$uri = $uri->withScheme(!empty($server['HTTPS']) && 'off' !== \strtolower($server['HTTPS']) ? 'https' : 'http');
179
+		$hasPort = \false;
180
+		if (isset($server['HTTP_HOST'])) {
181
+			$parts = \parse_url('http://' . $server['HTTP_HOST']);
182
+			$uri = $uri->withHost($parts['host'] ?? 'localhost');
183
+			if ($parts['port'] ?? \false) {
184
+				$hasPort = \true;
185
+				$uri = $uri->withPort($parts['port']);
186
+			}
187
+		} else {
188
+			$uri = $uri->withHost($server['SERVER_NAME'] ?? $server['SERVER_ADDR'] ?? 'localhost');
189
+		}
190
+		if (!$hasPort && isset($server['SERVER_PORT'])) {
191
+			$uri = $uri->withPort($server['SERVER_PORT']);
192
+		}
193
+		$hasQuery = \false;
194
+		if (isset($server['REQUEST_URI'])) {
195
+			$requestUriParts = \explode('?', $server['REQUEST_URI'], 2);
196
+			$uri = $uri->withPath($requestUriParts[0]);
197
+			if (isset($requestUriParts[1])) {
198
+				$hasQuery = \true;
199
+				$uri = $uri->withQuery($requestUriParts[1]);
200
+			}
201
+		}
202
+		if (!$hasQuery && isset($server['QUERY_STRING'])) {
203
+			$uri = $uri->withQuery($server['QUERY_STRING']);
204
+		}
205
+		return $uri;
206
+	}
207
+	private function normalizeFiles(array $files) : array
208
+	{
209
+		foreach ($files as $k => $v) {
210
+			if ($v instanceof UploadedFileInterface) {
211
+				continue;
212
+			}
213
+			if (!\is_array($v)) {
214
+				unset($files[$k]);
215
+			} elseif (!isset($v['tmp_name'])) {
216
+				$files[$k] = $this->normalizeFiles($v);
217
+			} else {
218
+				$files[$k] = $this->createUploadedFileFromSpec($v);
219
+			}
220
+		}
221
+		return $files;
222
+	}
223
+	/**
224
+	 * Create and return an UploadedFile instance from a $_FILES specification.
225
+	 *
226
+	 * @param array $value $_FILES struct
227
+	 *
228
+	 * @return UploadedFileInterface|UploadedFileInterface[]
229
+	 */
230
+	private function createUploadedFileFromSpec(array $value)
231
+	{
232
+		if (!\is_array($tmpName = $value['tmp_name'])) {
233
+			$file = \is_file($tmpName) ? $this->createStreamFromFile($tmpName, 'r') : $this->createStream();
234
+			return $this->createUploadedFile($file, $value['size'], $value['error'], $value['name'], $value['type']);
235
+		}
236
+		foreach ($tmpName as $k => $v) {
237
+			$tmpName[$k] = $this->createUploadedFileFromSpec(['tmp_name' => $v, 'size' => $value['size'][$k] ?? null, 'error' => $value['error'][$k] ?? null, 'name' => $value['name'][$k] ?? null, 'type' => $value['type'][$k] ?? null]);
238
+		}
239
+		return $tmpName;
240
+	}
241 241
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
160 160
                 $headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
161 161
             } elseif (isset($_SERVER['PHP_AUTH_USER'])) {
162
-                $headers['Authorization'] = 'Basic ' . \base64_encode($_SERVER['PHP_AUTH_USER'] . ':' . ($_SERVER['PHP_AUTH_PW'] ?? ''));
162
+                $headers['Authorization'] = 'Basic '.\base64_encode($_SERVER['PHP_AUTH_USER'].':'.($_SERVER['PHP_AUTH_PW'] ?? ''));
163 163
             } elseif (isset($_SERVER['PHP_AUTH_DIGEST'])) {
164 164
                 $headers['Authorization'] = $_SERVER['PHP_AUTH_DIGEST'];
165 165
             }
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
         $uri = $uri->withScheme(!empty($server['HTTPS']) && 'off' !== \strtolower($server['HTTPS']) ? 'https' : 'http');
179 179
         $hasPort = \false;
180 180
         if (isset($server['HTTP_HOST'])) {
181
-            $parts = \parse_url('http://' . $server['HTTP_HOST']);
181
+            $parts = \parse_url('http://'.$server['HTTP_HOST']);
182 182
             $uri = $uri->withHost($parts['host'] ?? 'localhost');
183 183
             if ($parts['port'] ?? \false) {
184 184
                 $hasPort = \true;
Please login to merge, or discard this patch.
lib/Vendor/Http/Discovery/Exception/DiscoveryFailedException.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -10,36 +10,36 @@
 block discarded – undo
10 10
  */
11 11
 final class DiscoveryFailedException extends \Exception implements Exception
12 12
 {
13
-    /**
14
-     * @var \Exception[]
15
-     */
16
-    private $exceptions;
17
-    /**
18
-     * @param string       $message
19
-     * @param \Exception[] $exceptions
20
-     */
21
-    public function __construct($message, array $exceptions = [])
22
-    {
23
-        $this->exceptions = $exceptions;
24
-        parent::__construct($message);
25
-    }
26
-    /**
27
-     * @param \Exception[] $exceptions
28
-     */
29
-    public static function create($exceptions)
30
-    {
31
-        $message = 'Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors';
32
-        foreach ($exceptions as $e) {
33
-            $message .= "\n - " . $e->getMessage();
34
-        }
35
-        $message .= "\n\n";
36
-        return new self($message, $exceptions);
37
-    }
38
-    /**
39
-     * @return \Exception[]
40
-     */
41
-    public function getExceptions()
42
-    {
43
-        return $this->exceptions;
44
-    }
13
+	/**
14
+	 * @var \Exception[]
15
+	 */
16
+	private $exceptions;
17
+	/**
18
+	 * @param string       $message
19
+	 * @param \Exception[] $exceptions
20
+	 */
21
+	public function __construct($message, array $exceptions = [])
22
+	{
23
+		$this->exceptions = $exceptions;
24
+		parent::__construct($message);
25
+	}
26
+	/**
27
+	 * @param \Exception[] $exceptions
28
+	 */
29
+	public static function create($exceptions)
30
+	{
31
+		$message = 'Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors';
32
+		foreach ($exceptions as $e) {
33
+			$message .= "\n - " . $e->getMessage();
34
+		}
35
+		$message .= "\n\n";
36
+		return new self($message, $exceptions);
37
+	}
38
+	/**
39
+	 * @return \Exception[]
40
+	 */
41
+	public function getExceptions()
42
+	{
43
+		return $this->exceptions;
44
+	}
45 45
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
     {
31 31
         $message = 'Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors';
32 32
         foreach ($exceptions as $e) {
33
-            $message .= "\n - " . $e->getMessage();
33
+            $message .= "\n - ".$e->getMessage();
34 34
         }
35 35
         $message .= "\n\n";
36 36
         return new self($message, $exceptions);
Please login to merge, or discard this patch.
lib/Vendor/Http/Discovery/Exception/NoCandidateFoundException.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -10,25 +10,25 @@
 block discarded – undo
10 10
  */
11 11
 final class NoCandidateFoundException extends \Exception implements Exception
12 12
 {
13
-    /**
14
-     * @param string $strategy
15
-     */
16
-    public function __construct($strategy, array $candidates)
17
-    {
18
-        $classes = \array_map(function ($a) {
19
-            return $a['class'];
20
-        }, $candidates);
21
-        $message = \sprintf('No valid candidate found using strategy "%s". We tested the following candidates: %s.', $strategy, \implode(', ', \array_map([$this, 'stringify'], $classes)));
22
-        parent::__construct($message);
23
-    }
24
-    private function stringify($mixed)
25
-    {
26
-        if (\is_string($mixed)) {
27
-            return $mixed;
28
-        }
29
-        if (\is_array($mixed) && 2 === \count($mixed)) {
30
-            return \sprintf('%s::%s', $this->stringify($mixed[0]), $mixed[1]);
31
-        }
32
-        return \is_object($mixed) ? \get_class($mixed) : \gettype($mixed);
33
-    }
13
+	/**
14
+	 * @param string $strategy
15
+	 */
16
+	public function __construct($strategy, array $candidates)
17
+	{
18
+		$classes = \array_map(function ($a) {
19
+			return $a['class'];
20
+		}, $candidates);
21
+		$message = \sprintf('No valid candidate found using strategy "%s". We tested the following candidates: %s.', $strategy, \implode(', ', \array_map([$this, 'stringify'], $classes)));
22
+		parent::__construct($message);
23
+	}
24
+	private function stringify($mixed)
25
+	{
26
+		if (\is_string($mixed)) {
27
+			return $mixed;
28
+		}
29
+		if (\is_array($mixed) && 2 === \count($mixed)) {
30
+			return \sprintf('%s::%s', $this->stringify($mixed[0]), $mixed[1]);
31
+		}
32
+		return \is_object($mixed) ? \get_class($mixed) : \gettype($mixed);
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
      */
16 16
     public function __construct($strategy, array $candidates)
17 17
     {
18
-        $classes = \array_map(function ($a) {
18
+        $classes = \array_map(function($a) {
19 19
             return $a['class'];
20 20
         }, $candidates);
21 21
         $message = \sprintf('No valid candidate found using strategy "%s". We tested the following candidates: %s.', $strategy, \implode(', ', \array_map([$this, 'stringify'], $classes)));
Please login to merge, or discard this patch.
lib/Vendor/Http/Discovery/Psr17FactoryDiscovery.php 3 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -17,103 +17,103 @@
 block discarded – undo
17 17
  */
18 18
 final class Psr17FactoryDiscovery extends ClassDiscovery
19 19
 {
20
-    private static function createException($type, Exception $e)
21
-    {
22
-        return new RealNotFoundException('No PSR-17 ' . $type . ' found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation', 0, $e);
23
-    }
24
-    /**
25
-     * @return RequestFactoryInterface
26
-     *
27
-     * @throws RealNotFoundException
28
-     */
29
-    public static function findRequestFactory()
30
-    {
31
-        try {
32
-            $messageFactory = static::findOneByType(RequestFactoryInterface::class);
33
-        } catch (DiscoveryFailedException $e) {
34
-            throw self::createException('request factory', $e);
35
-        }
36
-        return static::instantiateClass($messageFactory);
37
-    }
38
-    /**
39
-     * @return ResponseFactoryInterface
40
-     *
41
-     * @throws RealNotFoundException
42
-     */
43
-    public static function findResponseFactory()
44
-    {
45
-        try {
46
-            $messageFactory = static::findOneByType(ResponseFactoryInterface::class);
47
-        } catch (DiscoveryFailedException $e) {
48
-            throw self::createException('response factory', $e);
49
-        }
50
-        return static::instantiateClass($messageFactory);
51
-    }
52
-    /**
53
-     * @return ServerRequestFactoryInterface
54
-     *
55
-     * @throws RealNotFoundException
56
-     */
57
-    public static function findServerRequestFactory()
58
-    {
59
-        try {
60
-            $messageFactory = static::findOneByType(ServerRequestFactoryInterface::class);
61
-        } catch (DiscoveryFailedException $e) {
62
-            throw self::createException('server request factory', $e);
63
-        }
64
-        return static::instantiateClass($messageFactory);
65
-    }
66
-    /**
67
-     * @return StreamFactoryInterface
68
-     *
69
-     * @throws RealNotFoundException
70
-     */
71
-    public static function findStreamFactory()
72
-    {
73
-        try {
74
-            $messageFactory = static::findOneByType(StreamFactoryInterface::class);
75
-        } catch (DiscoveryFailedException $e) {
76
-            throw self::createException('stream factory', $e);
77
-        }
78
-        return static::instantiateClass($messageFactory);
79
-    }
80
-    /**
81
-     * @return UploadedFileFactoryInterface
82
-     *
83
-     * @throws RealNotFoundException
84
-     */
85
-    public static function findUploadedFileFactory()
86
-    {
87
-        try {
88
-            $messageFactory = static::findOneByType(UploadedFileFactoryInterface::class);
89
-        } catch (DiscoveryFailedException $e) {
90
-            throw self::createException('uploaded file factory', $e);
91
-        }
92
-        return static::instantiateClass($messageFactory);
93
-    }
94
-    /**
95
-     * @return UriFactoryInterface
96
-     *
97
-     * @throws RealNotFoundException
98
-     */
99
-    public static function findUriFactory()
100
-    {
101
-        try {
102
-            $messageFactory = static::findOneByType(UriFactoryInterface::class);
103
-        } catch (DiscoveryFailedException $e) {
104
-            throw self::createException('url factory', $e);
105
-        }
106
-        return static::instantiateClass($messageFactory);
107
-    }
108
-    /**
109
-     * @return UriFactoryInterface
110
-     *
111
-     * @throws RealNotFoundException
112
-     *
113
-     * @deprecated This will be removed in 2.0. Consider using the findUriFactory() method.
114
-     */
115
-    public static function findUrlFactory()
116
-    {
117
-        return static::findUriFactory();
118
-    }
20
+	private static function createException($type, Exception $e)
21
+	{
22
+		return new RealNotFoundException('No PSR-17 ' . $type . ' found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation', 0, $e);
23
+	}
24
+	/**
25
+	 * @return RequestFactoryInterface
26
+	 *
27
+	 * @throws RealNotFoundException
28
+	 */
29
+	public static function findRequestFactory()
30
+	{
31
+		try {
32
+			$messageFactory = static::findOneByType(RequestFactoryInterface::class);
33
+		} catch (DiscoveryFailedException $e) {
34
+			throw self::createException('request factory', $e);
35
+		}
36
+		return static::instantiateClass($messageFactory);
37
+	}
38
+	/**
39
+	 * @return ResponseFactoryInterface
40
+	 *
41
+	 * @throws RealNotFoundException
42
+	 */
43
+	public static function findResponseFactory()
44
+	{
45
+		try {
46
+			$messageFactory = static::findOneByType(ResponseFactoryInterface::class);
47
+		} catch (DiscoveryFailedException $e) {
48
+			throw self::createException('response factory', $e);
49
+		}
50
+		return static::instantiateClass($messageFactory);
51
+	}
52
+	/**
53
+	 * @return ServerRequestFactoryInterface
54
+	 *
55
+	 * @throws RealNotFoundException
56
+	 */
57
+	public static function findServerRequestFactory()
58
+	{
59
+		try {
60
+			$messageFactory = static::findOneByType(ServerRequestFactoryInterface::class);
61
+		} catch (DiscoveryFailedException $e) {
62
+			throw self::createException('server request factory', $e);
63
+		}
64
+		return static::instantiateClass($messageFactory);
65
+	}
66
+	/**
67
+	 * @return StreamFactoryInterface
68
+	 *
69
+	 * @throws RealNotFoundException
70
+	 */
71
+	public static function findStreamFactory()
72
+	{
73
+		try {
74
+			$messageFactory = static::findOneByType(StreamFactoryInterface::class);
75
+		} catch (DiscoveryFailedException $e) {
76
+			throw self::createException('stream factory', $e);
77
+		}
78
+		return static::instantiateClass($messageFactory);
79
+	}
80
+	/**
81
+	 * @return UploadedFileFactoryInterface
82
+	 *
83
+	 * @throws RealNotFoundException
84
+	 */
85
+	public static function findUploadedFileFactory()
86
+	{
87
+		try {
88
+			$messageFactory = static::findOneByType(UploadedFileFactoryInterface::class);
89
+		} catch (DiscoveryFailedException $e) {
90
+			throw self::createException('uploaded file factory', $e);
91
+		}
92
+		return static::instantiateClass($messageFactory);
93
+	}
94
+	/**
95
+	 * @return UriFactoryInterface
96
+	 *
97
+	 * @throws RealNotFoundException
98
+	 */
99
+	public static function findUriFactory()
100
+	{
101
+		try {
102
+			$messageFactory = static::findOneByType(UriFactoryInterface::class);
103
+		} catch (DiscoveryFailedException $e) {
104
+			throw self::createException('url factory', $e);
105
+		}
106
+		return static::instantiateClass($messageFactory);
107
+	}
108
+	/**
109
+	 * @return UriFactoryInterface
110
+	 *
111
+	 * @throws RealNotFoundException
112
+	 *
113
+	 * @deprecated This will be removed in 2.0. Consider using the findUriFactory() method.
114
+	 */
115
+	public static function findUrlFactory()
116
+	{
117
+		return static::findUriFactory();
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 {
20 20
     private static function createException($type, Exception $e)
21 21
     {
22
-        return new RealNotFoundException('No PSR-17 ' . $type . ' found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation', 0, $e);
22
+        return new RealNotFoundException('No PSR-17 '.$type.' found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation', 0, $e);
23 23
     }
24 24
     /**
25 25
      * @return RequestFactoryInterface
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,7 @@
 block discarded – undo
15 15
  *
16 16
  * @author Tobias Nyholm <[email protected]>
17 17
  */
18
-final class Psr17FactoryDiscovery extends ClassDiscovery
19
-{
18
+final class Psr17FactoryDiscovery extends ClassDiscovery {
20 19
     private static function createException($type, Exception $e)
21 20
     {
22 21
         return new RealNotFoundException('No PSR-17 ' . $type . ' found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation', 0, $e);
Please login to merge, or discard this patch.
lib/Vendor/Http/Discovery/NotFoundException.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,6 +10,5 @@
 block discarded – undo
10 10
  *
11 11
  * @deprecated since since version 1.0, and will be removed in 2.0. Use {@link \Http\Discovery\Exception\NotFoundException} instead.
12 12
  */
13
-final class NotFoundException extends RealNotFoundException
14
-{
13
+final class NotFoundException extends RealNotFoundException {
15 14
 }
Please login to merge, or discard this patch.
lib/Vendor/Http/Discovery/Psr18Client.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@
 block discarded – undo
19 19
  *
20 20
  * @author Nicolas Grekas <[email protected]>
21 21
  */
22
-class Psr18Client extends Psr17Factory implements ClientInterface
23
-{
22
+class Psr18Client extends Psr17Factory implements ClientInterface {
24 23
     private $client;
25 24
     public function __construct(?ClientInterface $client = null, ?RequestFactoryInterface $requestFactory = null, ?ResponseFactoryInterface $responseFactory = null, ?ServerRequestFactoryInterface $serverRequestFactory = null, ?StreamFactoryInterface $streamFactory = null, ?UploadedFileFactoryInterface $uploadedFileFactory = null, ?UriFactoryInterface $uriFactory = null)
26 25
     {
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -21,20 +21,20 @@
 block discarded – undo
21 21
  */
22 22
 class Psr18Client extends Psr17Factory implements ClientInterface
23 23
 {
24
-    private $client;
25
-    public function __construct(?ClientInterface $client = null, ?RequestFactoryInterface $requestFactory = null, ?ResponseFactoryInterface $responseFactory = null, ?ServerRequestFactoryInterface $serverRequestFactory = null, ?StreamFactoryInterface $streamFactory = null, ?UploadedFileFactoryInterface $uploadedFileFactory = null, ?UriFactoryInterface $uriFactory = null)
26
-    {
27
-        $requestFactory ?? ($requestFactory = $client instanceof RequestFactoryInterface ? $client : null);
28
-        $responseFactory ?? ($responseFactory = $client instanceof ResponseFactoryInterface ? $client : null);
29
-        $serverRequestFactory ?? ($serverRequestFactory = $client instanceof ServerRequestFactoryInterface ? $client : null);
30
-        $streamFactory ?? ($streamFactory = $client instanceof StreamFactoryInterface ? $client : null);
31
-        $uploadedFileFactory ?? ($uploadedFileFactory = $client instanceof UploadedFileFactoryInterface ? $client : null);
32
-        $uriFactory ?? ($uriFactory = $client instanceof UriFactoryInterface ? $client : null);
33
-        parent::__construct($requestFactory, $responseFactory, $serverRequestFactory, $streamFactory, $uploadedFileFactory, $uriFactory);
34
-        $this->client = $client ?? Psr18ClientDiscovery::find();
35
-    }
36
-    public function sendRequest(RequestInterface $request) : ResponseInterface
37
-    {
38
-        return $this->client->sendRequest($request);
39
-    }
24
+	private $client;
25
+	public function __construct(?ClientInterface $client = null, ?RequestFactoryInterface $requestFactory = null, ?ResponseFactoryInterface $responseFactory = null, ?ServerRequestFactoryInterface $serverRequestFactory = null, ?StreamFactoryInterface $streamFactory = null, ?UploadedFileFactoryInterface $uploadedFileFactory = null, ?UriFactoryInterface $uriFactory = null)
26
+	{
27
+		$requestFactory ?? ($requestFactory = $client instanceof RequestFactoryInterface ? $client : null);
28
+		$responseFactory ?? ($responseFactory = $client instanceof ResponseFactoryInterface ? $client : null);
29
+		$serverRequestFactory ?? ($serverRequestFactory = $client instanceof ServerRequestFactoryInterface ? $client : null);
30
+		$streamFactory ?? ($streamFactory = $client instanceof StreamFactoryInterface ? $client : null);
31
+		$uploadedFileFactory ?? ($uploadedFileFactory = $client instanceof UploadedFileFactoryInterface ? $client : null);
32
+		$uriFactory ?? ($uriFactory = $client instanceof UriFactoryInterface ? $client : null);
33
+		parent::__construct($requestFactory, $responseFactory, $serverRequestFactory, $streamFactory, $uploadedFileFactory, $uriFactory);
34
+		$this->client = $client ?? Psr18ClientDiscovery::find();
35
+	}
36
+	public function sendRequest(RequestInterface $request) : ResponseInterface
37
+	{
38
+		return $this->client->sendRequest($request);
39
+	}
40 40
 }
Please login to merge, or discard this patch.
lib/Vendor/Http/Discovery/Strategy/MockClientStrategy.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,11 +12,11 @@
 block discarded – undo
12 12
  */
13 13
 final class MockClientStrategy implements DiscoveryStrategy
14 14
 {
15
-    public static function getCandidates($type)
16
-    {
17
-        if (\is_a(HttpClient::class, $type, \true) || \is_a(HttpAsyncClient::class, $type, \true)) {
18
-            return [['class' => Mock::class, 'condition' => Mock::class]];
19
-        }
20
-        return [];
21
-    }
15
+	public static function getCandidates($type)
16
+	{
17
+		if (\is_a(HttpClient::class, $type, \true) || \is_a(HttpAsyncClient::class, $type, \true)) {
18
+			return [['class' => Mock::class, 'condition' => Mock::class]];
19
+		}
20
+		return [];
21
+	}
22 22
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@
 block discarded – undo
10 10
  *
11 11
  * @author Sam Rapaport <[email protected]>
12 12
  */
13
-final class MockClientStrategy implements DiscoveryStrategy
14
-{
13
+final class MockClientStrategy implements DiscoveryStrategy {
15 14
     public static function getCandidates($type)
16 15
     {
17 16
         if (\is_a(HttpClient::class, $type, \true) || \is_a(HttpAsyncClient::class, $type, \true)) {
Please login to merge, or discard this patch.