Completed
Push — master ( 8e973a...811a95 )
by
unknown
03:40 queued 01:04
created
lib/Vendor/GuzzleHttp/Psr7/Rfc7230.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@
 block discarded – undo
7 7
 /**
8 8
  * @internal
9 9
  */
10
-final class Rfc7230
11
-{
10
+final class Rfc7230 {
12 11
     /**
13 12
      * Header related regular expressions (based on amphp/http package)
14 13
      *
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,15 +8,15 @@
 block discarded – undo
8 8
  */
9 9
 final class Rfc7230
10 10
 {
11
-    /**
12
-     * Header related regular expressions (based on amphp/http package)
13
-     *
14
-     * Note: header delimiter (\r\n) is modified to \r?\n to accept line feed only delimiters for BC reasons.
15
-     *
16
-     * @see https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15
17
-     *
18
-     * @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
19
-     */
20
-    public const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\\]?={}\x01- ]++):[ \t]*+((?:[ \t]*+[!-~\x80-\xff]++)*+)[ \t]*+\r?\n)m";
21
-    public const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
11
+	/**
12
+	 * Header related regular expressions (based on amphp/http package)
13
+	 *
14
+	 * Note: header delimiter (\r\n) is modified to \r?\n to accept line feed only delimiters for BC reasons.
15
+	 *
16
+	 * @see https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15
17
+	 *
18
+	 * @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
19
+	 */
20
+	public const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\\]?={}\x01- ]++):[ \t]*+((?:[ \t]*+[!-~\x80-\xff]++)*+)[ \t]*+\r?\n)m";
21
+	public const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
22 22
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7;
5 5
 
6 6
 /**
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Psr7/Exception/MalformedUriException.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,6 +9,5 @@
 block discarded – undo
9 9
 /**
10 10
  * Exception thrown if a URI cannot be parsed because it's malformed.
11 11
  */
12
-class MalformedUriException extends InvalidArgumentException
13
-{
12
+class MalformedUriException extends InvalidArgumentException {
14 13
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7\Exception;
5 5
 
6 6
 use InvalidArgumentException;
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Psr7/UriResolver.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
  *
14 14
  * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5
15 15
  */
16
-final class UriResolver
17
-{
16
+final class UriResolver {
18 17
     /**
19 18
      * Removes dot segments from a path and returns the new path.
20 19
      *
Please login to merge, or discard this patch.
Indentation   +164 added lines, -164 removed lines patch added patch discarded remove patch
@@ -13,168 +13,168 @@
 block discarded – undo
13 13
  */
14 14
 final class UriResolver
15 15
 {
16
-    /**
17
-     * Removes dot segments from a path and returns the new path.
18
-     *
19
-     * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
20
-     */
21
-    public static function removeDotSegments(string $path) : string
22
-    {
23
-        if ($path === '' || $path === '/') {
24
-            return $path;
25
-        }
26
-        $results = [];
27
-        $segments = \explode('/', $path);
28
-        foreach ($segments as $segment) {
29
-            if ($segment === '..') {
30
-                \array_pop($results);
31
-            } elseif ($segment !== '.') {
32
-                $results[] = $segment;
33
-            }
34
-        }
35
-        $newPath = \implode('/', $results);
36
-        if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !== '/')) {
37
-            // Re-add the leading slash if necessary for cases like "/.."
38
-            $newPath = '/' . $newPath;
39
-        } elseif ($newPath !== '' && ($segment === '.' || $segment === '..')) {
40
-            // Add the trailing slash if necessary
41
-            // If newPath is not empty, then $segment must be set and is the last segment from the foreach
42
-            $newPath .= '/';
43
-        }
44
-        return $newPath;
45
-    }
46
-    /**
47
-     * Converts the relative URI into a new URI that is resolved against the base URI.
48
-     *
49
-     * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2
50
-     */
51
-    public static function resolve(UriInterface $base, UriInterface $rel) : UriInterface
52
-    {
53
-        if ((string) $rel === '') {
54
-            // we can simply return the same base URI instance for this same-document reference
55
-            return $base;
56
-        }
57
-        if ($rel->getScheme() != '') {
58
-            return $rel->withPath(self::removeDotSegments($rel->getPath()));
59
-        }
60
-        if ($rel->getAuthority() != '') {
61
-            $targetAuthority = $rel->getAuthority();
62
-            $targetPath = self::removeDotSegments($rel->getPath());
63
-            $targetQuery = $rel->getQuery();
64
-        } else {
65
-            $targetAuthority = $base->getAuthority();
66
-            if ($rel->getPath() === '') {
67
-                $targetPath = $base->getPath();
68
-                $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery();
69
-            } else {
70
-                if ($rel->getPath()[0] === '/') {
71
-                    $targetPath = $rel->getPath();
72
-                } else {
73
-                    if ($targetAuthority != '' && $base->getPath() === '') {
74
-                        $targetPath = '/' . $rel->getPath();
75
-                    } else {
76
-                        $lastSlashPos = \strrpos($base->getPath(), '/');
77
-                        if ($lastSlashPos === \false) {
78
-                            $targetPath = $rel->getPath();
79
-                        } else {
80
-                            $targetPath = \substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath();
81
-                        }
82
-                    }
83
-                }
84
-                $targetPath = self::removeDotSegments($targetPath);
85
-                $targetQuery = $rel->getQuery();
86
-            }
87
-        }
88
-        return new Uri(Uri::composeComponents($base->getScheme(), $targetAuthority, $targetPath, $targetQuery, $rel->getFragment()));
89
-    }
90
-    /**
91
-     * Returns the target URI as a relative reference from the base URI.
92
-     *
93
-     * This method is the counterpart to resolve():
94
-     *
95
-     *    (string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
96
-     *
97
-     * One use-case is to use the current request URI as base URI and then generate relative links in your documents
98
-     * to reduce the document size or offer self-contained downloadable document archives.
99
-     *
100
-     *    $base = new Uri('http://example.com/a/b/');
101
-     *    echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c'));  // prints 'c'.
102
-     *    echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y'));  // prints '../x/y'.
103
-     *    echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
104
-     *    echo UriResolver::relativize($base, new Uri('http://example.org/a/b/'));   // prints '//example.org/a/b/'.
105
-     *
106
-     * This method also accepts a target that is already relative and will try to relativize it further. Only a
107
-     * relative-path reference will be returned as-is.
108
-     *
109
-     *    echo UriResolver::relativize($base, new Uri('/a/b/c'));  // prints 'c' as well
110
-     */
111
-    public static function relativize(UriInterface $base, UriInterface $target) : UriInterface
112
-    {
113
-        if ($target->getScheme() !== '' && ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '')) {
114
-            return $target;
115
-        }
116
-        if (Uri::isRelativePathReference($target)) {
117
-            // As the target is already highly relative we return it as-is. It would be possible to resolve
118
-            // the target with `$target = self::resolve($base, $target);` and then try make it more relative
119
-            // by removing a duplicate query. But let's not do that automatically.
120
-            return $target;
121
-        }
122
-        if ($target->getAuthority() !== '' && $base->getAuthority() !== $target->getAuthority()) {
123
-            return $target->withScheme('');
124
-        }
125
-        // We must remove the path before removing the authority because if the path starts with two slashes, the URI
126
-        // would turn invalid. And we also cannot set a relative path before removing the authority, as that is also
127
-        // invalid.
128
-        $emptyPathUri = $target->withScheme('')->withPath('')->withUserInfo('')->withPort(null)->withHost('');
129
-        if ($base->getPath() !== $target->getPath()) {
130
-            return $emptyPathUri->withPath(self::getRelativePath($base, $target));
131
-        }
132
-        if ($base->getQuery() === $target->getQuery()) {
133
-            // Only the target fragment is left. And it must be returned even if base and target fragment are the same.
134
-            return $emptyPathUri->withQuery('');
135
-        }
136
-        // If the base URI has a query but the target has none, we cannot return an empty path reference as it would
137
-        // inherit the base query component when resolving.
138
-        if ($target->getQuery() === '') {
139
-            $segments = \explode('/', $target->getPath());
140
-            /** @var string $lastSegment */
141
-            $lastSegment = \end($segments);
142
-            return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment);
143
-        }
144
-        return $emptyPathUri;
145
-    }
146
-    private static function getRelativePath(UriInterface $base, UriInterface $target) : string
147
-    {
148
-        $sourceSegments = \explode('/', $base->getPath());
149
-        $targetSegments = \explode('/', $target->getPath());
150
-        \array_pop($sourceSegments);
151
-        $targetLastSegment = \array_pop($targetSegments);
152
-        foreach ($sourceSegments as $i => $segment) {
153
-            if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) {
154
-                unset($sourceSegments[$i], $targetSegments[$i]);
155
-            } else {
156
-                break;
157
-            }
158
-        }
159
-        $targetSegments[] = $targetLastSegment;
160
-        $relativePath = \str_repeat('../', \count($sourceSegments)) . \implode('/', $targetSegments);
161
-        // A reference to am empty last segment or an empty first sub-segment must be prefixed with "./".
162
-        // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
163
-        // as the first segment of a relative-path reference, as it would be mistaken for a scheme name.
164
-        if ('' === $relativePath || \false !== \strpos(\explode('/', $relativePath, 2)[0], ':')) {
165
-            $relativePath = "./{$relativePath}";
166
-        } elseif ('/' === $relativePath[0]) {
167
-            if ($base->getAuthority() != '' && $base->getPath() === '') {
168
-                // In this case an extra slash is added by resolve() automatically. So we must not add one here.
169
-                $relativePath = ".{$relativePath}";
170
-            } else {
171
-                $relativePath = "./{$relativePath}";
172
-            }
173
-        }
174
-        return $relativePath;
175
-    }
176
-    private function __construct()
177
-    {
178
-        // cannot be instantiated
179
-    }
16
+	/**
17
+	 * Removes dot segments from a path and returns the new path.
18
+	 *
19
+	 * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
20
+	 */
21
+	public static function removeDotSegments(string $path) : string
22
+	{
23
+		if ($path === '' || $path === '/') {
24
+			return $path;
25
+		}
26
+		$results = [];
27
+		$segments = \explode('/', $path);
28
+		foreach ($segments as $segment) {
29
+			if ($segment === '..') {
30
+				\array_pop($results);
31
+			} elseif ($segment !== '.') {
32
+				$results[] = $segment;
33
+			}
34
+		}
35
+		$newPath = \implode('/', $results);
36
+		if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !== '/')) {
37
+			// Re-add the leading slash if necessary for cases like "/.."
38
+			$newPath = '/' . $newPath;
39
+		} elseif ($newPath !== '' && ($segment === '.' || $segment === '..')) {
40
+			// Add the trailing slash if necessary
41
+			// If newPath is not empty, then $segment must be set and is the last segment from the foreach
42
+			$newPath .= '/';
43
+		}
44
+		return $newPath;
45
+	}
46
+	/**
47
+	 * Converts the relative URI into a new URI that is resolved against the base URI.
48
+	 *
49
+	 * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2
50
+	 */
51
+	public static function resolve(UriInterface $base, UriInterface $rel) : UriInterface
52
+	{
53
+		if ((string) $rel === '') {
54
+			// we can simply return the same base URI instance for this same-document reference
55
+			return $base;
56
+		}
57
+		if ($rel->getScheme() != '') {
58
+			return $rel->withPath(self::removeDotSegments($rel->getPath()));
59
+		}
60
+		if ($rel->getAuthority() != '') {
61
+			$targetAuthority = $rel->getAuthority();
62
+			$targetPath = self::removeDotSegments($rel->getPath());
63
+			$targetQuery = $rel->getQuery();
64
+		} else {
65
+			$targetAuthority = $base->getAuthority();
66
+			if ($rel->getPath() === '') {
67
+				$targetPath = $base->getPath();
68
+				$targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery();
69
+			} else {
70
+				if ($rel->getPath()[0] === '/') {
71
+					$targetPath = $rel->getPath();
72
+				} else {
73
+					if ($targetAuthority != '' && $base->getPath() === '') {
74
+						$targetPath = '/' . $rel->getPath();
75
+					} else {
76
+						$lastSlashPos = \strrpos($base->getPath(), '/');
77
+						if ($lastSlashPos === \false) {
78
+							$targetPath = $rel->getPath();
79
+						} else {
80
+							$targetPath = \substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath();
81
+						}
82
+					}
83
+				}
84
+				$targetPath = self::removeDotSegments($targetPath);
85
+				$targetQuery = $rel->getQuery();
86
+			}
87
+		}
88
+		return new Uri(Uri::composeComponents($base->getScheme(), $targetAuthority, $targetPath, $targetQuery, $rel->getFragment()));
89
+	}
90
+	/**
91
+	 * Returns the target URI as a relative reference from the base URI.
92
+	 *
93
+	 * This method is the counterpart to resolve():
94
+	 *
95
+	 *    (string) $target === (string) UriResolver::resolve($base, UriResolver::relativize($base, $target))
96
+	 *
97
+	 * One use-case is to use the current request URI as base URI and then generate relative links in your documents
98
+	 * to reduce the document size or offer self-contained downloadable document archives.
99
+	 *
100
+	 *    $base = new Uri('http://example.com/a/b/');
101
+	 *    echo UriResolver::relativize($base, new Uri('http://example.com/a/b/c'));  // prints 'c'.
102
+	 *    echo UriResolver::relativize($base, new Uri('http://example.com/a/x/y'));  // prints '../x/y'.
103
+	 *    echo UriResolver::relativize($base, new Uri('http://example.com/a/b/?q')); // prints '?q'.
104
+	 *    echo UriResolver::relativize($base, new Uri('http://example.org/a/b/'));   // prints '//example.org/a/b/'.
105
+	 *
106
+	 * This method also accepts a target that is already relative and will try to relativize it further. Only a
107
+	 * relative-path reference will be returned as-is.
108
+	 *
109
+	 *    echo UriResolver::relativize($base, new Uri('/a/b/c'));  // prints 'c' as well
110
+	 */
111
+	public static function relativize(UriInterface $base, UriInterface $target) : UriInterface
112
+	{
113
+		if ($target->getScheme() !== '' && ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '')) {
114
+			return $target;
115
+		}
116
+		if (Uri::isRelativePathReference($target)) {
117
+			// As the target is already highly relative we return it as-is. It would be possible to resolve
118
+			// the target with `$target = self::resolve($base, $target);` and then try make it more relative
119
+			// by removing a duplicate query. But let's not do that automatically.
120
+			return $target;
121
+		}
122
+		if ($target->getAuthority() !== '' && $base->getAuthority() !== $target->getAuthority()) {
123
+			return $target->withScheme('');
124
+		}
125
+		// We must remove the path before removing the authority because if the path starts with two slashes, the URI
126
+		// would turn invalid. And we also cannot set a relative path before removing the authority, as that is also
127
+		// invalid.
128
+		$emptyPathUri = $target->withScheme('')->withPath('')->withUserInfo('')->withPort(null)->withHost('');
129
+		if ($base->getPath() !== $target->getPath()) {
130
+			return $emptyPathUri->withPath(self::getRelativePath($base, $target));
131
+		}
132
+		if ($base->getQuery() === $target->getQuery()) {
133
+			// Only the target fragment is left. And it must be returned even if base and target fragment are the same.
134
+			return $emptyPathUri->withQuery('');
135
+		}
136
+		// If the base URI has a query but the target has none, we cannot return an empty path reference as it would
137
+		// inherit the base query component when resolving.
138
+		if ($target->getQuery() === '') {
139
+			$segments = \explode('/', $target->getPath());
140
+			/** @var string $lastSegment */
141
+			$lastSegment = \end($segments);
142
+			return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment);
143
+		}
144
+		return $emptyPathUri;
145
+	}
146
+	private static function getRelativePath(UriInterface $base, UriInterface $target) : string
147
+	{
148
+		$sourceSegments = \explode('/', $base->getPath());
149
+		$targetSegments = \explode('/', $target->getPath());
150
+		\array_pop($sourceSegments);
151
+		$targetLastSegment = \array_pop($targetSegments);
152
+		foreach ($sourceSegments as $i => $segment) {
153
+			if (isset($targetSegments[$i]) && $segment === $targetSegments[$i]) {
154
+				unset($sourceSegments[$i], $targetSegments[$i]);
155
+			} else {
156
+				break;
157
+			}
158
+		}
159
+		$targetSegments[] = $targetLastSegment;
160
+		$relativePath = \str_repeat('../', \count($sourceSegments)) . \implode('/', $targetSegments);
161
+		// A reference to am empty last segment or an empty first sub-segment must be prefixed with "./".
162
+		// This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
163
+		// as the first segment of a relative-path reference, as it would be mistaken for a scheme name.
164
+		if ('' === $relativePath || \false !== \strpos(\explode('/', $relativePath, 2)[0], ':')) {
165
+			$relativePath = "./{$relativePath}";
166
+		} elseif ('/' === $relativePath[0]) {
167
+			if ($base->getAuthority() != '' && $base->getPath() === '') {
168
+				// In this case an extra slash is added by resolve() automatically. So we must not add one here.
169
+				$relativePath = ".{$relativePath}";
170
+			} else {
171
+				$relativePath = "./{$relativePath}";
172
+			}
173
+		}
174
+		return $relativePath;
175
+	}
176
+	private function __construct()
177
+	{
178
+		// cannot be instantiated
179
+	}
180 180
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7;
5 5
 
6 6
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\UriInterface;
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $newPath = \implode('/', $results);
36 36
         if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !== '/')) {
37 37
             // Re-add the leading slash if necessary for cases like "/.."
38
-            $newPath = '/' . $newPath;
38
+            $newPath = '/'.$newPath;
39 39
         } elseif ($newPath !== '' && ($segment === '.' || $segment === '..')) {
40 40
             // Add the trailing slash if necessary
41 41
             // If newPath is not empty, then $segment must be set and is the last segment from the foreach
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public static function resolve(UriInterface $base, UriInterface $rel) : UriInterface
52 52
     {
53
-        if ((string) $rel === '') {
53
+        if ((string)$rel === '') {
54 54
             // we can simply return the same base URI instance for this same-document reference
55 55
             return $base;
56 56
         }
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
                     $targetPath = $rel->getPath();
72 72
                 } else {
73 73
                     if ($targetAuthority != '' && $base->getPath() === '') {
74
-                        $targetPath = '/' . $rel->getPath();
74
+                        $targetPath = '/'.$rel->getPath();
75 75
                     } else {
76 76
                         $lastSlashPos = \strrpos($base->getPath(), '/');
77 77
                         if ($lastSlashPos === \false) {
78 78
                             $targetPath = $rel->getPath();
79 79
                         } else {
80
-                            $targetPath = \substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath();
80
+                            $targetPath = \substr($base->getPath(), 0, $lastSlashPos + 1).$rel->getPath();
81 81
                         }
82 82
                     }
83 83
                 }
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             }
158 158
         }
159 159
         $targetSegments[] = $targetLastSegment;
160
-        $relativePath = \str_repeat('../', \count($sourceSegments)) . \implode('/', $targetSegments);
160
+        $relativePath = \str_repeat('../', \count($sourceSegments)).\implode('/', $targetSegments);
161 161
         // A reference to am empty last segment or an empty first sub-segment must be prefixed with "./".
162 162
         // This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
163 163
         // as the first segment of a relative-path reference, as it would be mistaken for a scheme name.
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Psr7/ServerRequest.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@
 block discarded – undo
24 24
  * implemented such that they retain the internal state of the current
25 25
  * message and return a new instance that contains the changed state.
26 26
  */
27
-class ServerRequest extends Request implements ServerRequestInterface
28
-{
27
+class ServerRequest extends Request implements ServerRequestInterface {
29 28
     /**
30 29
      * @var array
31 30
      */
Please login to merge, or discard this patch.
Indentation   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -24,243 +24,243 @@
 block discarded – undo
24 24
  */
25 25
 class ServerRequest extends Request implements ServerRequestInterface
26 26
 {
27
-    /**
28
-     * @var array
29
-     */
30
-    private $attributes = [];
31
-    /**
32
-     * @var array
33
-     */
34
-    private $cookieParams = [];
35
-    /**
36
-     * @var array|object|null
37
-     */
38
-    private $parsedBody;
39
-    /**
40
-     * @var array
41
-     */
42
-    private $queryParams = [];
43
-    /**
44
-     * @var array
45
-     */
46
-    private $serverParams;
47
-    /**
48
-     * @var array
49
-     */
50
-    private $uploadedFiles = [];
51
-    /**
52
-     * @param string                               $method       HTTP method
53
-     * @param string|UriInterface                  $uri          URI
54
-     * @param (string|string[])[]                  $headers      Request headers
55
-     * @param string|resource|StreamInterface|null $body         Request body
56
-     * @param string                               $version      Protocol version
57
-     * @param array                                $serverParams Typically the $_SERVER superglobal
58
-     */
59
-    public function __construct(string $method, $uri, array $headers = [], $body = null, string $version = '1.1', array $serverParams = [])
60
-    {
61
-        $this->serverParams = $serverParams;
62
-        parent::__construct($method, $uri, $headers, $body, $version);
63
-    }
64
-    /**
65
-     * Return an UploadedFile instance array.
66
-     *
67
-     * @param array $files An array which respect $_FILES structure
68
-     *
69
-     * @throws InvalidArgumentException for unrecognized values
70
-     */
71
-    public static function normalizeFiles(array $files) : array
72
-    {
73
-        $normalized = [];
74
-        foreach ($files as $key => $value) {
75
-            if ($value instanceof UploadedFileInterface) {
76
-                $normalized[$key] = $value;
77
-            } elseif (\is_array($value) && isset($value['tmp_name'])) {
78
-                $normalized[$key] = self::createUploadedFileFromSpec($value);
79
-            } elseif (\is_array($value)) {
80
-                $normalized[$key] = self::normalizeFiles($value);
81
-                continue;
82
-            } else {
83
-                throw new InvalidArgumentException('Invalid value in files specification');
84
-            }
85
-        }
86
-        return $normalized;
87
-    }
88
-    /**
89
-     * Create and return an UploadedFile instance from a $_FILES specification.
90
-     *
91
-     * If the specification represents an array of values, this method will
92
-     * delegate to normalizeNestedFileSpec() and return that return value.
93
-     *
94
-     * @param array $value $_FILES struct
95
-     *
96
-     * @return UploadedFileInterface|UploadedFileInterface[]
97
-     */
98
-    private static function createUploadedFileFromSpec(array $value)
99
-    {
100
-        if (\is_array($value['tmp_name'])) {
101
-            return self::normalizeNestedFileSpec($value);
102
-        }
103
-        return new UploadedFile($value['tmp_name'], (int) $value['size'], (int) $value['error'], $value['name'], $value['type']);
104
-    }
105
-    /**
106
-     * Normalize an array of file specifications.
107
-     *
108
-     * Loops through all nested files and returns a normalized array of
109
-     * UploadedFileInterface instances.
110
-     *
111
-     * @return UploadedFileInterface[]
112
-     */
113
-    private static function normalizeNestedFileSpec(array $files = []) : array
114
-    {
115
-        $normalizedFiles = [];
116
-        foreach (\array_keys($files['tmp_name']) as $key) {
117
-            $spec = ['tmp_name' => $files['tmp_name'][$key], 'size' => $files['size'][$key] ?? null, 'error' => $files['error'][$key] ?? null, 'name' => $files['name'][$key] ?? null, 'type' => $files['type'][$key] ?? null];
118
-            $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
119
-        }
120
-        return $normalizedFiles;
121
-    }
122
-    /**
123
-     * Return a ServerRequest populated with superglobals:
124
-     * $_GET
125
-     * $_POST
126
-     * $_COOKIE
127
-     * $_FILES
128
-     * $_SERVER
129
-     */
130
-    public static function fromGlobals() : ServerRequestInterface
131
-    {
132
-        $method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
133
-        $headers = \getallheaders();
134
-        $uri = self::getUriFromGlobals();
135
-        $body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
136
-        $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
137
-        $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER);
138
-        return $serverRequest->withCookieParams($_COOKIE)->withQueryParams($_GET)->withParsedBody($_POST)->withUploadedFiles(self::normalizeFiles($_FILES));
139
-    }
140
-    private static function extractHostAndPortFromAuthority(string $authority) : array
141
-    {
142
-        $uri = 'http://' . $authority;
143
-        $parts = \parse_url($uri);
144
-        if (\false === $parts) {
145
-            return [null, null];
146
-        }
147
-        $host = $parts['host'] ?? null;
148
-        $port = $parts['port'] ?? null;
149
-        return [$host, $port];
150
-    }
151
-    /**
152
-     * Get a Uri populated with values from $_SERVER.
153
-     */
154
-    public static function getUriFromGlobals() : UriInterface
155
-    {
156
-        $uri = new Uri('');
157
-        $uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
158
-        $hasPort = \false;
159
-        if (isset($_SERVER['HTTP_HOST'])) {
160
-            [$host, $port] = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
161
-            if ($host !== null) {
162
-                $uri = $uri->withHost($host);
163
-            }
164
-            if ($port !== null) {
165
-                $hasPort = \true;
166
-                $uri = $uri->withPort($port);
167
-            }
168
-        } elseif (isset($_SERVER['SERVER_NAME'])) {
169
-            $uri = $uri->withHost($_SERVER['SERVER_NAME']);
170
-        } elseif (isset($_SERVER['SERVER_ADDR'])) {
171
-            $uri = $uri->withHost($_SERVER['SERVER_ADDR']);
172
-        }
173
-        if (!$hasPort && isset($_SERVER['SERVER_PORT'])) {
174
-            $uri = $uri->withPort($_SERVER['SERVER_PORT']);
175
-        }
176
-        $hasQuery = \false;
177
-        if (isset($_SERVER['REQUEST_URI'])) {
178
-            $requestUriParts = \explode('?', $_SERVER['REQUEST_URI'], 2);
179
-            $uri = $uri->withPath($requestUriParts[0]);
180
-            if (isset($requestUriParts[1])) {
181
-                $hasQuery = \true;
182
-                $uri = $uri->withQuery($requestUriParts[1]);
183
-            }
184
-        }
185
-        if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) {
186
-            $uri = $uri->withQuery($_SERVER['QUERY_STRING']);
187
-        }
188
-        return $uri;
189
-    }
190
-    public function getServerParams() : array
191
-    {
192
-        return $this->serverParams;
193
-    }
194
-    public function getUploadedFiles() : array
195
-    {
196
-        return $this->uploadedFiles;
197
-    }
198
-    public function withUploadedFiles(array $uploadedFiles) : ServerRequestInterface
199
-    {
200
-        $new = clone $this;
201
-        $new->uploadedFiles = $uploadedFiles;
202
-        return $new;
203
-    }
204
-    public function getCookieParams() : array
205
-    {
206
-        return $this->cookieParams;
207
-    }
208
-    public function withCookieParams(array $cookies) : ServerRequestInterface
209
-    {
210
-        $new = clone $this;
211
-        $new->cookieParams = $cookies;
212
-        return $new;
213
-    }
214
-    public function getQueryParams() : array
215
-    {
216
-        return $this->queryParams;
217
-    }
218
-    public function withQueryParams(array $query) : ServerRequestInterface
219
-    {
220
-        $new = clone $this;
221
-        $new->queryParams = $query;
222
-        return $new;
223
-    }
224
-    /**
225
-     * @return array|object|null
226
-     */
227
-    public function getParsedBody()
228
-    {
229
-        return $this->parsedBody;
230
-    }
231
-    public function withParsedBody($data) : ServerRequestInterface
232
-    {
233
-        $new = clone $this;
234
-        $new->parsedBody = $data;
235
-        return $new;
236
-    }
237
-    public function getAttributes() : array
238
-    {
239
-        return $this->attributes;
240
-    }
241
-    /**
242
-     * @return mixed
243
-     */
244
-    public function getAttribute($attribute, $default = null)
245
-    {
246
-        if (\false === \array_key_exists($attribute, $this->attributes)) {
247
-            return $default;
248
-        }
249
-        return $this->attributes[$attribute];
250
-    }
251
-    public function withAttribute($attribute, $value) : ServerRequestInterface
252
-    {
253
-        $new = clone $this;
254
-        $new->attributes[$attribute] = $value;
255
-        return $new;
256
-    }
257
-    public function withoutAttribute($attribute) : ServerRequestInterface
258
-    {
259
-        if (\false === \array_key_exists($attribute, $this->attributes)) {
260
-            return $this;
261
-        }
262
-        $new = clone $this;
263
-        unset($new->attributes[$attribute]);
264
-        return $new;
265
-    }
27
+	/**
28
+	 * @var array
29
+	 */
30
+	private $attributes = [];
31
+	/**
32
+	 * @var array
33
+	 */
34
+	private $cookieParams = [];
35
+	/**
36
+	 * @var array|object|null
37
+	 */
38
+	private $parsedBody;
39
+	/**
40
+	 * @var array
41
+	 */
42
+	private $queryParams = [];
43
+	/**
44
+	 * @var array
45
+	 */
46
+	private $serverParams;
47
+	/**
48
+	 * @var array
49
+	 */
50
+	private $uploadedFiles = [];
51
+	/**
52
+	 * @param string                               $method       HTTP method
53
+	 * @param string|UriInterface                  $uri          URI
54
+	 * @param (string|string[])[]                  $headers      Request headers
55
+	 * @param string|resource|StreamInterface|null $body         Request body
56
+	 * @param string                               $version      Protocol version
57
+	 * @param array                                $serverParams Typically the $_SERVER superglobal
58
+	 */
59
+	public function __construct(string $method, $uri, array $headers = [], $body = null, string $version = '1.1', array $serverParams = [])
60
+	{
61
+		$this->serverParams = $serverParams;
62
+		parent::__construct($method, $uri, $headers, $body, $version);
63
+	}
64
+	/**
65
+	 * Return an UploadedFile instance array.
66
+	 *
67
+	 * @param array $files An array which respect $_FILES structure
68
+	 *
69
+	 * @throws InvalidArgumentException for unrecognized values
70
+	 */
71
+	public static function normalizeFiles(array $files) : array
72
+	{
73
+		$normalized = [];
74
+		foreach ($files as $key => $value) {
75
+			if ($value instanceof UploadedFileInterface) {
76
+				$normalized[$key] = $value;
77
+			} elseif (\is_array($value) && isset($value['tmp_name'])) {
78
+				$normalized[$key] = self::createUploadedFileFromSpec($value);
79
+			} elseif (\is_array($value)) {
80
+				$normalized[$key] = self::normalizeFiles($value);
81
+				continue;
82
+			} else {
83
+				throw new InvalidArgumentException('Invalid value in files specification');
84
+			}
85
+		}
86
+		return $normalized;
87
+	}
88
+	/**
89
+	 * Create and return an UploadedFile instance from a $_FILES specification.
90
+	 *
91
+	 * If the specification represents an array of values, this method will
92
+	 * delegate to normalizeNestedFileSpec() and return that return value.
93
+	 *
94
+	 * @param array $value $_FILES struct
95
+	 *
96
+	 * @return UploadedFileInterface|UploadedFileInterface[]
97
+	 */
98
+	private static function createUploadedFileFromSpec(array $value)
99
+	{
100
+		if (\is_array($value['tmp_name'])) {
101
+			return self::normalizeNestedFileSpec($value);
102
+		}
103
+		return new UploadedFile($value['tmp_name'], (int) $value['size'], (int) $value['error'], $value['name'], $value['type']);
104
+	}
105
+	/**
106
+	 * Normalize an array of file specifications.
107
+	 *
108
+	 * Loops through all nested files and returns a normalized array of
109
+	 * UploadedFileInterface instances.
110
+	 *
111
+	 * @return UploadedFileInterface[]
112
+	 */
113
+	private static function normalizeNestedFileSpec(array $files = []) : array
114
+	{
115
+		$normalizedFiles = [];
116
+		foreach (\array_keys($files['tmp_name']) as $key) {
117
+			$spec = ['tmp_name' => $files['tmp_name'][$key], 'size' => $files['size'][$key] ?? null, 'error' => $files['error'][$key] ?? null, 'name' => $files['name'][$key] ?? null, 'type' => $files['type'][$key] ?? null];
118
+			$normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
119
+		}
120
+		return $normalizedFiles;
121
+	}
122
+	/**
123
+	 * Return a ServerRequest populated with superglobals:
124
+	 * $_GET
125
+	 * $_POST
126
+	 * $_COOKIE
127
+	 * $_FILES
128
+	 * $_SERVER
129
+	 */
130
+	public static function fromGlobals() : ServerRequestInterface
131
+	{
132
+		$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
133
+		$headers = \getallheaders();
134
+		$uri = self::getUriFromGlobals();
135
+		$body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
136
+		$protocol = isset($_SERVER['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1';
137
+		$serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER);
138
+		return $serverRequest->withCookieParams($_COOKIE)->withQueryParams($_GET)->withParsedBody($_POST)->withUploadedFiles(self::normalizeFiles($_FILES));
139
+	}
140
+	private static function extractHostAndPortFromAuthority(string $authority) : array
141
+	{
142
+		$uri = 'http://' . $authority;
143
+		$parts = \parse_url($uri);
144
+		if (\false === $parts) {
145
+			return [null, null];
146
+		}
147
+		$host = $parts['host'] ?? null;
148
+		$port = $parts['port'] ?? null;
149
+		return [$host, $port];
150
+	}
151
+	/**
152
+	 * Get a Uri populated with values from $_SERVER.
153
+	 */
154
+	public static function getUriFromGlobals() : UriInterface
155
+	{
156
+		$uri = new Uri('');
157
+		$uri = $uri->withScheme(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' ? 'https' : 'http');
158
+		$hasPort = \false;
159
+		if (isset($_SERVER['HTTP_HOST'])) {
160
+			[$host, $port] = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
161
+			if ($host !== null) {
162
+				$uri = $uri->withHost($host);
163
+			}
164
+			if ($port !== null) {
165
+				$hasPort = \true;
166
+				$uri = $uri->withPort($port);
167
+			}
168
+		} elseif (isset($_SERVER['SERVER_NAME'])) {
169
+			$uri = $uri->withHost($_SERVER['SERVER_NAME']);
170
+		} elseif (isset($_SERVER['SERVER_ADDR'])) {
171
+			$uri = $uri->withHost($_SERVER['SERVER_ADDR']);
172
+		}
173
+		if (!$hasPort && isset($_SERVER['SERVER_PORT'])) {
174
+			$uri = $uri->withPort($_SERVER['SERVER_PORT']);
175
+		}
176
+		$hasQuery = \false;
177
+		if (isset($_SERVER['REQUEST_URI'])) {
178
+			$requestUriParts = \explode('?', $_SERVER['REQUEST_URI'], 2);
179
+			$uri = $uri->withPath($requestUriParts[0]);
180
+			if (isset($requestUriParts[1])) {
181
+				$hasQuery = \true;
182
+				$uri = $uri->withQuery($requestUriParts[1]);
183
+			}
184
+		}
185
+		if (!$hasQuery && isset($_SERVER['QUERY_STRING'])) {
186
+			$uri = $uri->withQuery($_SERVER['QUERY_STRING']);
187
+		}
188
+		return $uri;
189
+	}
190
+	public function getServerParams() : array
191
+	{
192
+		return $this->serverParams;
193
+	}
194
+	public function getUploadedFiles() : array
195
+	{
196
+		return $this->uploadedFiles;
197
+	}
198
+	public function withUploadedFiles(array $uploadedFiles) : ServerRequestInterface
199
+	{
200
+		$new = clone $this;
201
+		$new->uploadedFiles = $uploadedFiles;
202
+		return $new;
203
+	}
204
+	public function getCookieParams() : array
205
+	{
206
+		return $this->cookieParams;
207
+	}
208
+	public function withCookieParams(array $cookies) : ServerRequestInterface
209
+	{
210
+		$new = clone $this;
211
+		$new->cookieParams = $cookies;
212
+		return $new;
213
+	}
214
+	public function getQueryParams() : array
215
+	{
216
+		return $this->queryParams;
217
+	}
218
+	public function withQueryParams(array $query) : ServerRequestInterface
219
+	{
220
+		$new = clone $this;
221
+		$new->queryParams = $query;
222
+		return $new;
223
+	}
224
+	/**
225
+	 * @return array|object|null
226
+	 */
227
+	public function getParsedBody()
228
+	{
229
+		return $this->parsedBody;
230
+	}
231
+	public function withParsedBody($data) : ServerRequestInterface
232
+	{
233
+		$new = clone $this;
234
+		$new->parsedBody = $data;
235
+		return $new;
236
+	}
237
+	public function getAttributes() : array
238
+	{
239
+		return $this->attributes;
240
+	}
241
+	/**
242
+	 * @return mixed
243
+	 */
244
+	public function getAttribute($attribute, $default = null)
245
+	{
246
+		if (\false === \array_key_exists($attribute, $this->attributes)) {
247
+			return $default;
248
+		}
249
+		return $this->attributes[$attribute];
250
+	}
251
+	public function withAttribute($attribute, $value) : ServerRequestInterface
252
+	{
253
+		$new = clone $this;
254
+		$new->attributes[$attribute] = $value;
255
+		return $new;
256
+	}
257
+	public function withoutAttribute($attribute) : ServerRequestInterface
258
+	{
259
+		if (\false === \array_key_exists($attribute, $this->attributes)) {
260
+			return $this;
261
+		}
262
+		$new = clone $this;
263
+		unset($new->attributes[$attribute]);
264
+		return $new;
265
+	}
266 266
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7;
5 5
 
6 6
 use InvalidArgumentException;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         if (\is_array($value['tmp_name'])) {
101 101
             return self::normalizeNestedFileSpec($value);
102 102
         }
103
-        return new UploadedFile($value['tmp_name'], (int) $value['size'], (int) $value['error'], $value['name'], $value['type']);
103
+        return new UploadedFile($value['tmp_name'], (int)$value['size'], (int)$value['error'], $value['name'], $value['type']);
104 104
     }
105 105
     /**
106 106
      * Normalize an array of file specifications.
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     }
140 140
     private static function extractHostAndPortFromAuthority(string $authority) : array
141 141
     {
142
-        $uri = 'http://' . $authority;
142
+        $uri = 'http://'.$authority;
143 143
         $parts = \parse_url($uri);
144 144
         if (\false === $parts) {
145 145
             return [null, null];
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Psr7/Stream.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,8 +9,7 @@
 block discarded – undo
9 9
 /**
10 10
  * PHP stream implementation.
11 11
  */
12
-class Stream implements StreamInterface
13
-{
12
+class Stream implements StreamInterface {
14 13
     /**
15 14
      * @see https://www.php.net/manual/en/function.fopen.php
16 15
      * @see https://www.php.net/manual/en/function.gzopen.php
Please login to merge, or discard this patch.
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -9,227 +9,227 @@
 block discarded – undo
9 9
  */
10 10
 class Stream implements StreamInterface
11 11
 {
12
-    /**
13
-     * @see https://www.php.net/manual/en/function.fopen.php
14
-     * @see https://www.php.net/manual/en/function.gzopen.php
15
-     */
16
-    private const READABLE_MODES = '/r|a\\+|ab\\+|w\\+|wb\\+|x\\+|xb\\+|c\\+|cb\\+/';
17
-    private const WRITABLE_MODES = '/a|w|r\\+|rb\\+|rw|x|c/';
18
-    /** @var resource */
19
-    private $stream;
20
-    /** @var int|null */
21
-    private $size;
22
-    /** @var bool */
23
-    private $seekable;
24
-    /** @var bool */
25
-    private $readable;
26
-    /** @var bool */
27
-    private $writable;
28
-    /** @var string|null */
29
-    private $uri;
30
-    /** @var mixed[] */
31
-    private $customMetadata;
32
-    /**
33
-     * This constructor accepts an associative array of options.
34
-     *
35
-     * - size: (int) If a read stream would otherwise have an indeterminate
36
-     *   size, but the size is known due to foreknowledge, then you can
37
-     *   provide that size, in bytes.
38
-     * - metadata: (array) Any additional metadata to return when the metadata
39
-     *   of the stream is accessed.
40
-     *
41
-     * @param resource                            $stream  Stream resource to wrap.
42
-     * @param array{size?: int, metadata?: array} $options Associative array of options.
43
-     *
44
-     * @throws \InvalidArgumentException if the stream is not a stream resource
45
-     */
46
-    public function __construct($stream, array $options = [])
47
-    {
48
-        if (!\is_resource($stream)) {
49
-            throw new \InvalidArgumentException('Stream must be a resource');
50
-        }
51
-        if (isset($options['size'])) {
52
-            $this->size = $options['size'];
53
-        }
54
-        $this->customMetadata = $options['metadata'] ?? [];
55
-        $this->stream = $stream;
56
-        $meta = \stream_get_meta_data($this->stream);
57
-        $this->seekable = $meta['seekable'];
58
-        $this->readable = (bool) \preg_match(self::READABLE_MODES, $meta['mode']);
59
-        $this->writable = (bool) \preg_match(self::WRITABLE_MODES, $meta['mode']);
60
-        $this->uri = $this->getMetadata('uri');
61
-    }
62
-    /**
63
-     * Closes the stream when the destructed
64
-     */
65
-    public function __destruct()
66
-    {
67
-        $this->close();
68
-    }
69
-    public function __toString() : string
70
-    {
71
-        try {
72
-            if ($this->isSeekable()) {
73
-                $this->seek(0);
74
-            }
75
-            return $this->getContents();
76
-        } catch (\Throwable $e) {
77
-            if (\PHP_VERSION_ID >= 70400) {
78
-                throw $e;
79
-            }
80
-            \trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
81
-            return '';
82
-        }
83
-    }
84
-    public function getContents() : string
85
-    {
86
-        if (!isset($this->stream)) {
87
-            throw new \RuntimeException('Stream is detached');
88
-        }
89
-        if (!$this->readable) {
90
-            throw new \RuntimeException('Cannot read from non-readable stream');
91
-        }
92
-        return Utils::tryGetContents($this->stream);
93
-    }
94
-    public function close() : void
95
-    {
96
-        if (isset($this->stream)) {
97
-            if (\is_resource($this->stream)) {
98
-                \fclose($this->stream);
99
-            }
100
-            $this->detach();
101
-        }
102
-    }
103
-    public function detach()
104
-    {
105
-        if (!isset($this->stream)) {
106
-            return null;
107
-        }
108
-        $result = $this->stream;
109
-        unset($this->stream);
110
-        $this->size = $this->uri = null;
111
-        $this->readable = $this->writable = $this->seekable = \false;
112
-        return $result;
113
-    }
114
-    public function getSize() : ?int
115
-    {
116
-        if ($this->size !== null) {
117
-            return $this->size;
118
-        }
119
-        if (!isset($this->stream)) {
120
-            return null;
121
-        }
122
-        // Clear the stat cache if the stream has a URI
123
-        if ($this->uri) {
124
-            \clearstatcache(\true, $this->uri);
125
-        }
126
-        $stats = \fstat($this->stream);
127
-        if (\is_array($stats) && isset($stats['size'])) {
128
-            $this->size = $stats['size'];
129
-            return $this->size;
130
-        }
131
-        return null;
132
-    }
133
-    public function isReadable() : bool
134
-    {
135
-        return $this->readable;
136
-    }
137
-    public function isWritable() : bool
138
-    {
139
-        return $this->writable;
140
-    }
141
-    public function isSeekable() : bool
142
-    {
143
-        return $this->seekable;
144
-    }
145
-    public function eof() : bool
146
-    {
147
-        if (!isset($this->stream)) {
148
-            throw new \RuntimeException('Stream is detached');
149
-        }
150
-        return \feof($this->stream);
151
-    }
152
-    public function tell() : int
153
-    {
154
-        if (!isset($this->stream)) {
155
-            throw new \RuntimeException('Stream is detached');
156
-        }
157
-        $result = \ftell($this->stream);
158
-        if ($result === \false) {
159
-            throw new \RuntimeException('Unable to determine stream position');
160
-        }
161
-        return $result;
162
-    }
163
-    public function rewind() : void
164
-    {
165
-        $this->seek(0);
166
-    }
167
-    public function seek($offset, $whence = \SEEK_SET) : void
168
-    {
169
-        $whence = (int) $whence;
170
-        if (!isset($this->stream)) {
171
-            throw new \RuntimeException('Stream is detached');
172
-        }
173
-        if (!$this->seekable) {
174
-            throw new \RuntimeException('Stream is not seekable');
175
-        }
176
-        if (\fseek($this->stream, $offset, $whence) === -1) {
177
-            throw new \RuntimeException('Unable to seek to stream position ' . $offset . ' with whence ' . \var_export($whence, \true));
178
-        }
179
-    }
180
-    public function read($length) : string
181
-    {
182
-        if (!isset($this->stream)) {
183
-            throw new \RuntimeException('Stream is detached');
184
-        }
185
-        if (!$this->readable) {
186
-            throw new \RuntimeException('Cannot read from non-readable stream');
187
-        }
188
-        if ($length < 0) {
189
-            throw new \RuntimeException('Length parameter cannot be negative');
190
-        }
191
-        if (0 === $length) {
192
-            return '';
193
-        }
194
-        try {
195
-            $string = \fread($this->stream, $length);
196
-        } catch (\Exception $e) {
197
-            throw new \RuntimeException('Unable to read from stream', 0, $e);
198
-        }
199
-        if (\false === $string) {
200
-            throw new \RuntimeException('Unable to read from stream');
201
-        }
202
-        return $string;
203
-    }
204
-    public function write($string) : int
205
-    {
206
-        if (!isset($this->stream)) {
207
-            throw new \RuntimeException('Stream is detached');
208
-        }
209
-        if (!$this->writable) {
210
-            throw new \RuntimeException('Cannot write to a non-writable stream');
211
-        }
212
-        // We can't know the size after writing anything
213
-        $this->size = null;
214
-        $result = \fwrite($this->stream, $string);
215
-        if ($result === \false) {
216
-            throw new \RuntimeException('Unable to write to stream');
217
-        }
218
-        return $result;
219
-    }
220
-    /**
221
-     * @return mixed
222
-     */
223
-    public function getMetadata($key = null)
224
-    {
225
-        if (!isset($this->stream)) {
226
-            return $key ? null : [];
227
-        } elseif (!$key) {
228
-            return $this->customMetadata + \stream_get_meta_data($this->stream);
229
-        } elseif (isset($this->customMetadata[$key])) {
230
-            return $this->customMetadata[$key];
231
-        }
232
-        $meta = \stream_get_meta_data($this->stream);
233
-        return $meta[$key] ?? null;
234
-    }
12
+	/**
13
+	 * @see https://www.php.net/manual/en/function.fopen.php
14
+	 * @see https://www.php.net/manual/en/function.gzopen.php
15
+	 */
16
+	private const READABLE_MODES = '/r|a\\+|ab\\+|w\\+|wb\\+|x\\+|xb\\+|c\\+|cb\\+/';
17
+	private const WRITABLE_MODES = '/a|w|r\\+|rb\\+|rw|x|c/';
18
+	/** @var resource */
19
+	private $stream;
20
+	/** @var int|null */
21
+	private $size;
22
+	/** @var bool */
23
+	private $seekable;
24
+	/** @var bool */
25
+	private $readable;
26
+	/** @var bool */
27
+	private $writable;
28
+	/** @var string|null */
29
+	private $uri;
30
+	/** @var mixed[] */
31
+	private $customMetadata;
32
+	/**
33
+	 * This constructor accepts an associative array of options.
34
+	 *
35
+	 * - size: (int) If a read stream would otherwise have an indeterminate
36
+	 *   size, but the size is known due to foreknowledge, then you can
37
+	 *   provide that size, in bytes.
38
+	 * - metadata: (array) Any additional metadata to return when the metadata
39
+	 *   of the stream is accessed.
40
+	 *
41
+	 * @param resource                            $stream  Stream resource to wrap.
42
+	 * @param array{size?: int, metadata?: array} $options Associative array of options.
43
+	 *
44
+	 * @throws \InvalidArgumentException if the stream is not a stream resource
45
+	 */
46
+	public function __construct($stream, array $options = [])
47
+	{
48
+		if (!\is_resource($stream)) {
49
+			throw new \InvalidArgumentException('Stream must be a resource');
50
+		}
51
+		if (isset($options['size'])) {
52
+			$this->size = $options['size'];
53
+		}
54
+		$this->customMetadata = $options['metadata'] ?? [];
55
+		$this->stream = $stream;
56
+		$meta = \stream_get_meta_data($this->stream);
57
+		$this->seekable = $meta['seekable'];
58
+		$this->readable = (bool) \preg_match(self::READABLE_MODES, $meta['mode']);
59
+		$this->writable = (bool) \preg_match(self::WRITABLE_MODES, $meta['mode']);
60
+		$this->uri = $this->getMetadata('uri');
61
+	}
62
+	/**
63
+	 * Closes the stream when the destructed
64
+	 */
65
+	public function __destruct()
66
+	{
67
+		$this->close();
68
+	}
69
+	public function __toString() : string
70
+	{
71
+		try {
72
+			if ($this->isSeekable()) {
73
+				$this->seek(0);
74
+			}
75
+			return $this->getContents();
76
+		} catch (\Throwable $e) {
77
+			if (\PHP_VERSION_ID >= 70400) {
78
+				throw $e;
79
+			}
80
+			\trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
81
+			return '';
82
+		}
83
+	}
84
+	public function getContents() : string
85
+	{
86
+		if (!isset($this->stream)) {
87
+			throw new \RuntimeException('Stream is detached');
88
+		}
89
+		if (!$this->readable) {
90
+			throw new \RuntimeException('Cannot read from non-readable stream');
91
+		}
92
+		return Utils::tryGetContents($this->stream);
93
+	}
94
+	public function close() : void
95
+	{
96
+		if (isset($this->stream)) {
97
+			if (\is_resource($this->stream)) {
98
+				\fclose($this->stream);
99
+			}
100
+			$this->detach();
101
+		}
102
+	}
103
+	public function detach()
104
+	{
105
+		if (!isset($this->stream)) {
106
+			return null;
107
+		}
108
+		$result = $this->stream;
109
+		unset($this->stream);
110
+		$this->size = $this->uri = null;
111
+		$this->readable = $this->writable = $this->seekable = \false;
112
+		return $result;
113
+	}
114
+	public function getSize() : ?int
115
+	{
116
+		if ($this->size !== null) {
117
+			return $this->size;
118
+		}
119
+		if (!isset($this->stream)) {
120
+			return null;
121
+		}
122
+		// Clear the stat cache if the stream has a URI
123
+		if ($this->uri) {
124
+			\clearstatcache(\true, $this->uri);
125
+		}
126
+		$stats = \fstat($this->stream);
127
+		if (\is_array($stats) && isset($stats['size'])) {
128
+			$this->size = $stats['size'];
129
+			return $this->size;
130
+		}
131
+		return null;
132
+	}
133
+	public function isReadable() : bool
134
+	{
135
+		return $this->readable;
136
+	}
137
+	public function isWritable() : bool
138
+	{
139
+		return $this->writable;
140
+	}
141
+	public function isSeekable() : bool
142
+	{
143
+		return $this->seekable;
144
+	}
145
+	public function eof() : bool
146
+	{
147
+		if (!isset($this->stream)) {
148
+			throw new \RuntimeException('Stream is detached');
149
+		}
150
+		return \feof($this->stream);
151
+	}
152
+	public function tell() : int
153
+	{
154
+		if (!isset($this->stream)) {
155
+			throw new \RuntimeException('Stream is detached');
156
+		}
157
+		$result = \ftell($this->stream);
158
+		if ($result === \false) {
159
+			throw new \RuntimeException('Unable to determine stream position');
160
+		}
161
+		return $result;
162
+	}
163
+	public function rewind() : void
164
+	{
165
+		$this->seek(0);
166
+	}
167
+	public function seek($offset, $whence = \SEEK_SET) : void
168
+	{
169
+		$whence = (int) $whence;
170
+		if (!isset($this->stream)) {
171
+			throw new \RuntimeException('Stream is detached');
172
+		}
173
+		if (!$this->seekable) {
174
+			throw new \RuntimeException('Stream is not seekable');
175
+		}
176
+		if (\fseek($this->stream, $offset, $whence) === -1) {
177
+			throw new \RuntimeException('Unable to seek to stream position ' . $offset . ' with whence ' . \var_export($whence, \true));
178
+		}
179
+	}
180
+	public function read($length) : string
181
+	{
182
+		if (!isset($this->stream)) {
183
+			throw new \RuntimeException('Stream is detached');
184
+		}
185
+		if (!$this->readable) {
186
+			throw new \RuntimeException('Cannot read from non-readable stream');
187
+		}
188
+		if ($length < 0) {
189
+			throw new \RuntimeException('Length parameter cannot be negative');
190
+		}
191
+		if (0 === $length) {
192
+			return '';
193
+		}
194
+		try {
195
+			$string = \fread($this->stream, $length);
196
+		} catch (\Exception $e) {
197
+			throw new \RuntimeException('Unable to read from stream', 0, $e);
198
+		}
199
+		if (\false === $string) {
200
+			throw new \RuntimeException('Unable to read from stream');
201
+		}
202
+		return $string;
203
+	}
204
+	public function write($string) : int
205
+	{
206
+		if (!isset($this->stream)) {
207
+			throw new \RuntimeException('Stream is detached');
208
+		}
209
+		if (!$this->writable) {
210
+			throw new \RuntimeException('Cannot write to a non-writable stream');
211
+		}
212
+		// We can't know the size after writing anything
213
+		$this->size = null;
214
+		$result = \fwrite($this->stream, $string);
215
+		if ($result === \false) {
216
+			throw new \RuntimeException('Unable to write to stream');
217
+		}
218
+		return $result;
219
+	}
220
+	/**
221
+	 * @return mixed
222
+	 */
223
+	public function getMetadata($key = null)
224
+	{
225
+		if (!isset($this->stream)) {
226
+			return $key ? null : [];
227
+		} elseif (!$key) {
228
+			return $this->customMetadata + \stream_get_meta_data($this->stream);
229
+		} elseif (isset($this->customMetadata[$key])) {
230
+			return $this->customMetadata[$key];
231
+		}
232
+		$meta = \stream_get_meta_data($this->stream);
233
+		return $meta[$key] ?? null;
234
+	}
235 235
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7;
5 5
 
6 6
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\StreamInterface;
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
         $this->stream = $stream;
56 56
         $meta = \stream_get_meta_data($this->stream);
57 57
         $this->seekable = $meta['seekable'];
58
-        $this->readable = (bool) \preg_match(self::READABLE_MODES, $meta['mode']);
59
-        $this->writable = (bool) \preg_match(self::WRITABLE_MODES, $meta['mode']);
58
+        $this->readable = (bool)\preg_match(self::READABLE_MODES, $meta['mode']);
59
+        $this->writable = (bool)\preg_match(self::WRITABLE_MODES, $meta['mode']);
60 60
         $this->uri = $this->getMetadata('uri');
61 61
     }
62 62
     /**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             if (\PHP_VERSION_ID >= 70400) {
78 78
                 throw $e;
79 79
             }
80
-            \trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string) $e), \E_USER_ERROR);
80
+            \trigger_error(\sprintf('%s::__toString exception: %s', self::class, (string)$e), \E_USER_ERROR);
81 81
             return '';
82 82
         }
83 83
     }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
     }
167 167
     public function seek($offset, $whence = \SEEK_SET) : void
168 168
     {
169
-        $whence = (int) $whence;
169
+        $whence = (int)$whence;
170 170
         if (!isset($this->stream)) {
171 171
             throw new \RuntimeException('Stream is detached');
172 172
         }
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
             throw new \RuntimeException('Stream is not seekable');
175 175
         }
176 176
         if (\fseek($this->stream, $offset, $whence) === -1) {
177
-            throw new \RuntimeException('Unable to seek to stream position ' . $offset . ' with whence ' . \var_export($whence, \true));
177
+            throw new \RuntimeException('Unable to seek to stream position '.$offset.' with whence '.\var_export($whence, \true));
178 178
         }
179 179
     }
180 180
     public function read($length) : string
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Psr7/UriNormalizer.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
  *
14 14
  * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6
15 15
  */
16
-final class UriNormalizer
17
-{
16
+final class UriNormalizer {
18 17
     /**
19 18
      * Default normalizations which only include the ones that preserve semantics.
20 19
      */
Please login to merge, or discard this patch.
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -13,163 +13,163 @@
 block discarded – undo
13 13
  */
14 14
 final class UriNormalizer
15 15
 {
16
-    /**
17
-     * Default normalizations which only include the ones that preserve semantics.
18
-     */
19
-    public const PRESERVING_NORMALIZATIONS = self::CAPITALIZE_PERCENT_ENCODING | self::DECODE_UNRESERVED_CHARACTERS | self::CONVERT_EMPTY_PATH | self::REMOVE_DEFAULT_HOST | self::REMOVE_DEFAULT_PORT | self::REMOVE_DOT_SEGMENTS;
20
-    /**
21
-     * All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
22
-     *
23
-     * Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b
24
-     */
25
-    public const CAPITALIZE_PERCENT_ENCODING = 1;
26
-    /**
27
-     * Decodes percent-encoded octets of unreserved characters.
28
-     *
29
-     * For consistency, percent-encoded octets in the ranges of ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39),
30
-     * hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should not be created by URI producers and,
31
-     * when found in a URI, should be decoded to their corresponding unreserved characters by URI normalizers.
32
-     *
33
-     * Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/
34
-     */
35
-    public const DECODE_UNRESERVED_CHARACTERS = 2;
36
-    /**
37
-     * Converts the empty path to "/" for http and https URIs.
38
-     *
39
-     * Example: http://example.org → http://example.org/
40
-     */
41
-    public const CONVERT_EMPTY_PATH = 4;
42
-    /**
43
-     * Removes the default host of the given URI scheme from the URI.
44
-     *
45
-     * Only the "file" scheme defines the default host "localhost".
46
-     * All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile`
47
-     * are equivalent according to RFC 3986. The first format is not accepted
48
-     * by PHPs stream functions and thus already normalized implicitly to the
49
-     * second format in the Uri class. See `GuzzleHttp\Psr7\Uri::composeComponents`.
50
-     *
51
-     * Example: file://localhost/myfile → file:///myfile
52
-     */
53
-    public const REMOVE_DEFAULT_HOST = 8;
54
-    /**
55
-     * Removes the default port of the given URI scheme from the URI.
56
-     *
57
-     * Example: http://example.org:80/ → http://example.org/
58
-     */
59
-    public const REMOVE_DEFAULT_PORT = 16;
60
-    /**
61
-     * Removes unnecessary dot-segments.
62
-     *
63
-     * Dot-segments in relative-path references are not removed as it would
64
-     * change the semantics of the URI reference.
65
-     *
66
-     * Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html
67
-     */
68
-    public const REMOVE_DOT_SEGMENTS = 32;
69
-    /**
70
-     * Paths which include two or more adjacent slashes are converted to one.
71
-     *
72
-     * Webservers usually ignore duplicate slashes and treat those URIs equivalent.
73
-     * But in theory those URIs do not need to be equivalent. So this normalization
74
-     * may change the semantics. Encoded slashes (%2F) are not removed.
75
-     *
76
-     * Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html
77
-     */
78
-    public const REMOVE_DUPLICATE_SLASHES = 64;
79
-    /**
80
-     * Sort query parameters with their values in alphabetical order.
81
-     *
82
-     * However, the order of parameters in a URI may be significant (this is not defined by the standard).
83
-     * So this normalization is not safe and may change the semantics of the URI.
84
-     *
85
-     * Example: ?lang=en&article=fred → ?article=fred&lang=en
86
-     *
87
-     * Note: The sorting is neither locale nor Unicode aware (the URI query does not get decoded at all) as the
88
-     * purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly.
89
-     */
90
-    public const SORT_QUERY_PARAMETERS = 128;
91
-    /**
92
-     * Returns a normalized URI.
93
-     *
94
-     * The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
95
-     * This methods adds additional normalizations that can be configured with the $flags parameter.
96
-     *
97
-     * PSR-7 UriInterface cannot distinguish between an empty component and a missing component as
98
-     * getQuery(), getFragment() etc. always return a string. This means the URIs "/?#" and "/" are
99
-     * treated equivalent which is not necessarily true according to RFC 3986. But that difference
100
-     * is highly uncommon in reality. So this potential normalization is implied in PSR-7 as well.
101
-     *
102
-     * @param UriInterface $uri   The URI to normalize
103
-     * @param int          $flags A bitmask of normalizations to apply, see constants
104
-     *
105
-     * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2
106
-     */
107
-    public static function normalize(UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS) : UriInterface
108
-    {
109
-        if ($flags & self::CAPITALIZE_PERCENT_ENCODING) {
110
-            $uri = self::capitalizePercentEncoding($uri);
111
-        }
112
-        if ($flags & self::DECODE_UNRESERVED_CHARACTERS) {
113
-            $uri = self::decodeUnreservedCharacters($uri);
114
-        }
115
-        if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === '' && ($uri->getScheme() === 'http' || $uri->getScheme() === 'https')) {
116
-            $uri = $uri->withPath('/');
117
-        }
118
-        if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') {
119
-            $uri = $uri->withHost('');
120
-        }
121
-        if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && Uri::isDefaultPort($uri)) {
122
-            $uri = $uri->withPort(null);
123
-        }
124
-        if ($flags & self::REMOVE_DOT_SEGMENTS && !Uri::isRelativePathReference($uri)) {
125
-            $uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath()));
126
-        }
127
-        if ($flags & self::REMOVE_DUPLICATE_SLASHES) {
128
-            $uri = $uri->withPath(\preg_replace('#//++#', '/', $uri->getPath()));
129
-        }
130
-        if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') {
131
-            $queryKeyValues = \explode('&', $uri->getQuery());
132
-            \sort($queryKeyValues);
133
-            $uri = $uri->withQuery(\implode('&', $queryKeyValues));
134
-        }
135
-        return $uri;
136
-    }
137
-    /**
138
-     * Whether two URIs can be considered equivalent.
139
-     *
140
-     * Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also
141
-     * accepts relative URI references and returns true when they are equivalent. This of course assumes they will be
142
-     * resolved against the same base URI. If this is not the case, determination of equivalence or difference of
143
-     * relative references does not mean anything.
144
-     *
145
-     * @param UriInterface $uri1           An URI to compare
146
-     * @param UriInterface $uri2           An URI to compare
147
-     * @param int          $normalizations A bitmask of normalizations to apply, see constants
148
-     *
149
-     * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.1
150
-     */
151
-    public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS) : bool
152
-    {
153
-        return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations);
154
-    }
155
-    private static function capitalizePercentEncoding(UriInterface $uri) : UriInterface
156
-    {
157
-        $regex = '/(?:%[A-Fa-f0-9]{2})++/';
158
-        $callback = function (array $match) : string {
159
-            return \strtoupper($match[0]);
160
-        };
161
-        return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
162
-    }
163
-    private static function decodeUnreservedCharacters(UriInterface $uri) : UriInterface
164
-    {
165
-        $regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
166
-        $callback = function (array $match) : string {
167
-            return \rawurldecode($match[0]);
168
-        };
169
-        return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
170
-    }
171
-    private function __construct()
172
-    {
173
-        // cannot be instantiated
174
-    }
16
+	/**
17
+	 * Default normalizations which only include the ones that preserve semantics.
18
+	 */
19
+	public const PRESERVING_NORMALIZATIONS = self::CAPITALIZE_PERCENT_ENCODING | self::DECODE_UNRESERVED_CHARACTERS | self::CONVERT_EMPTY_PATH | self::REMOVE_DEFAULT_HOST | self::REMOVE_DEFAULT_PORT | self::REMOVE_DOT_SEGMENTS;
20
+	/**
21
+	 * All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
22
+	 *
23
+	 * Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b
24
+	 */
25
+	public const CAPITALIZE_PERCENT_ENCODING = 1;
26
+	/**
27
+	 * Decodes percent-encoded octets of unreserved characters.
28
+	 *
29
+	 * For consistency, percent-encoded octets in the ranges of ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39),
30
+	 * hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E) should not be created by URI producers and,
31
+	 * when found in a URI, should be decoded to their corresponding unreserved characters by URI normalizers.
32
+	 *
33
+	 * Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/
34
+	 */
35
+	public const DECODE_UNRESERVED_CHARACTERS = 2;
36
+	/**
37
+	 * Converts the empty path to "/" for http and https URIs.
38
+	 *
39
+	 * Example: http://example.org → http://example.org/
40
+	 */
41
+	public const CONVERT_EMPTY_PATH = 4;
42
+	/**
43
+	 * Removes the default host of the given URI scheme from the URI.
44
+	 *
45
+	 * Only the "file" scheme defines the default host "localhost".
46
+	 * All of `file:/myfile`, `file:///myfile`, and `file://localhost/myfile`
47
+	 * are equivalent according to RFC 3986. The first format is not accepted
48
+	 * by PHPs stream functions and thus already normalized implicitly to the
49
+	 * second format in the Uri class. See `GuzzleHttp\Psr7\Uri::composeComponents`.
50
+	 *
51
+	 * Example: file://localhost/myfile → file:///myfile
52
+	 */
53
+	public const REMOVE_DEFAULT_HOST = 8;
54
+	/**
55
+	 * Removes the default port of the given URI scheme from the URI.
56
+	 *
57
+	 * Example: http://example.org:80/ → http://example.org/
58
+	 */
59
+	public const REMOVE_DEFAULT_PORT = 16;
60
+	/**
61
+	 * Removes unnecessary dot-segments.
62
+	 *
63
+	 * Dot-segments in relative-path references are not removed as it would
64
+	 * change the semantics of the URI reference.
65
+	 *
66
+	 * Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html
67
+	 */
68
+	public const REMOVE_DOT_SEGMENTS = 32;
69
+	/**
70
+	 * Paths which include two or more adjacent slashes are converted to one.
71
+	 *
72
+	 * Webservers usually ignore duplicate slashes and treat those URIs equivalent.
73
+	 * But in theory those URIs do not need to be equivalent. So this normalization
74
+	 * may change the semantics. Encoded slashes (%2F) are not removed.
75
+	 *
76
+	 * Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html
77
+	 */
78
+	public const REMOVE_DUPLICATE_SLASHES = 64;
79
+	/**
80
+	 * Sort query parameters with their values in alphabetical order.
81
+	 *
82
+	 * However, the order of parameters in a URI may be significant (this is not defined by the standard).
83
+	 * So this normalization is not safe and may change the semantics of the URI.
84
+	 *
85
+	 * Example: ?lang=en&article=fred → ?article=fred&lang=en
86
+	 *
87
+	 * Note: The sorting is neither locale nor Unicode aware (the URI query does not get decoded at all) as the
88
+	 * purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly.
89
+	 */
90
+	public const SORT_QUERY_PARAMETERS = 128;
91
+	/**
92
+	 * Returns a normalized URI.
93
+	 *
94
+	 * The scheme and host component are already normalized to lowercase per PSR-7 UriInterface.
95
+	 * This methods adds additional normalizations that can be configured with the $flags parameter.
96
+	 *
97
+	 * PSR-7 UriInterface cannot distinguish between an empty component and a missing component as
98
+	 * getQuery(), getFragment() etc. always return a string. This means the URIs "/?#" and "/" are
99
+	 * treated equivalent which is not necessarily true according to RFC 3986. But that difference
100
+	 * is highly uncommon in reality. So this potential normalization is implied in PSR-7 as well.
101
+	 *
102
+	 * @param UriInterface $uri   The URI to normalize
103
+	 * @param int          $flags A bitmask of normalizations to apply, see constants
104
+	 *
105
+	 * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2
106
+	 */
107
+	public static function normalize(UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS) : UriInterface
108
+	{
109
+		if ($flags & self::CAPITALIZE_PERCENT_ENCODING) {
110
+			$uri = self::capitalizePercentEncoding($uri);
111
+		}
112
+		if ($flags & self::DECODE_UNRESERVED_CHARACTERS) {
113
+			$uri = self::decodeUnreservedCharacters($uri);
114
+		}
115
+		if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === '' && ($uri->getScheme() === 'http' || $uri->getScheme() === 'https')) {
116
+			$uri = $uri->withPath('/');
117
+		}
118
+		if ($flags & self::REMOVE_DEFAULT_HOST && $uri->getScheme() === 'file' && $uri->getHost() === 'localhost') {
119
+			$uri = $uri->withHost('');
120
+		}
121
+		if ($flags & self::REMOVE_DEFAULT_PORT && $uri->getPort() !== null && Uri::isDefaultPort($uri)) {
122
+			$uri = $uri->withPort(null);
123
+		}
124
+		if ($flags & self::REMOVE_DOT_SEGMENTS && !Uri::isRelativePathReference($uri)) {
125
+			$uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath()));
126
+		}
127
+		if ($flags & self::REMOVE_DUPLICATE_SLASHES) {
128
+			$uri = $uri->withPath(\preg_replace('#//++#', '/', $uri->getPath()));
129
+		}
130
+		if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') {
131
+			$queryKeyValues = \explode('&', $uri->getQuery());
132
+			\sort($queryKeyValues);
133
+			$uri = $uri->withQuery(\implode('&', $queryKeyValues));
134
+		}
135
+		return $uri;
136
+	}
137
+	/**
138
+	 * Whether two URIs can be considered equivalent.
139
+	 *
140
+	 * Both URIs are normalized automatically before comparison with the given $normalizations bitmask. The method also
141
+	 * accepts relative URI references and returns true when they are equivalent. This of course assumes they will be
142
+	 * resolved against the same base URI. If this is not the case, determination of equivalence or difference of
143
+	 * relative references does not mean anything.
144
+	 *
145
+	 * @param UriInterface $uri1           An URI to compare
146
+	 * @param UriInterface $uri2           An URI to compare
147
+	 * @param int          $normalizations A bitmask of normalizations to apply, see constants
148
+	 *
149
+	 * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.1
150
+	 */
151
+	public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS) : bool
152
+	{
153
+		return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations);
154
+	}
155
+	private static function capitalizePercentEncoding(UriInterface $uri) : UriInterface
156
+	{
157
+		$regex = '/(?:%[A-Fa-f0-9]{2})++/';
158
+		$callback = function (array $match) : string {
159
+			return \strtoupper($match[0]);
160
+		};
161
+		return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
162
+	}
163
+	private static function decodeUnreservedCharacters(UriInterface $uri) : UriInterface
164
+	{
165
+		$regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
166
+		$callback = function (array $match) : string {
167
+			return \rawurldecode($match[0]);
168
+		};
169
+		return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
170
+	}
171
+	private function __construct()
172
+	{
173
+		// cannot be instantiated
174
+	}
175 175
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7;
5 5
 
6 6
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\UriInterface;
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS) : bool
152 152
     {
153
-        return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations);
153
+        return (string)self::normalize($uri1, $normalizations) === (string)self::normalize($uri2, $normalizations);
154 154
     }
155 155
     private static function capitalizePercentEncoding(UriInterface $uri) : UriInterface
156 156
     {
157 157
         $regex = '/(?:%[A-Fa-f0-9]{2})++/';
158
-        $callback = function (array $match) : string {
158
+        $callback = function(array $match) : string {
159 159
             return \strtoupper($match[0]);
160 160
         };
161 161
         return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
     private static function decodeUnreservedCharacters(UriInterface $uri) : UriInterface
164 164
     {
165 165
         $regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
166
-        $callback = function (array $match) : string {
166
+        $callback = function(array $match) : string {
167 167
             return \rawurldecode($match[0]);
168 168
         };
169 169
         return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery()));
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/Psr7/UriComparator.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@
 block discarded – undo
11 11
  *
12 12
  * @author Graham Campbell
13 13
  */
14
-final class UriComparator
15
-{
14
+final class UriComparator {
16 15
     /**
17 16
      * Determines if a modified URL should be considered cross-origin with
18 17
      * respect to an original URL.
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -11,33 +11,33 @@
 block discarded – undo
11 11
  */
12 12
 final class UriComparator
13 13
 {
14
-    /**
15
-     * Determines if a modified URL should be considered cross-origin with
16
-     * respect to an original URL.
17
-     */
18
-    public static function isCrossOrigin(UriInterface $original, UriInterface $modified) : bool
19
-    {
20
-        if (\strcasecmp($original->getHost(), $modified->getHost()) !== 0) {
21
-            return \true;
22
-        }
23
-        if ($original->getScheme() !== $modified->getScheme()) {
24
-            return \true;
25
-        }
26
-        if (self::computePort($original) !== self::computePort($modified)) {
27
-            return \true;
28
-        }
29
-        return \false;
30
-    }
31
-    private static function computePort(UriInterface $uri) : int
32
-    {
33
-        $port = $uri->getPort();
34
-        if (null !== $port) {
35
-            return $port;
36
-        }
37
-        return 'https' === $uri->getScheme() ? 443 : 80;
38
-    }
39
-    private function __construct()
40
-    {
41
-        // cannot be instantiated
42
-    }
14
+	/**
15
+	 * Determines if a modified URL should be considered cross-origin with
16
+	 * respect to an original URL.
17
+	 */
18
+	public static function isCrossOrigin(UriInterface $original, UriInterface $modified) : bool
19
+	{
20
+		if (\strcasecmp($original->getHost(), $modified->getHost()) !== 0) {
21
+			return \true;
22
+		}
23
+		if ($original->getScheme() !== $modified->getScheme()) {
24
+			return \true;
25
+		}
26
+		if (self::computePort($original) !== self::computePort($modified)) {
27
+			return \true;
28
+		}
29
+		return \false;
30
+	}
31
+	private static function computePort(UriInterface $uri) : int
32
+	{
33
+		$port = $uri->getPort();
34
+		if (null !== $port) {
35
+			return $port;
36
+		}
37
+		return 'https' === $uri->getScheme() ? 443 : 80;
38
+	}
39
+	private function __construct()
40
+	{
41
+		// cannot be instantiated
42
+	}
43 43
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-declare (strict_types=1);
3
+declare(strict_types=1);
4 4
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\GuzzleHttp\Psr7;
5 5
 
6 6
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\UriInterface;
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/RetryMiddleware.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
  *
14 14
  * @final
15 15
  */
16
-class RetryMiddleware
17
-{
16
+class RetryMiddleware {
18 17
     /**
19 18
      * @var callable(RequestInterface, array): PromiseInterface
20 19
      */
Please login to merge, or discard this patch.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -14,78 +14,78 @@
 block discarded – undo
14 14
  */
15 15
 class RetryMiddleware
16 16
 {
17
-    /**
18
-     * @var callable(RequestInterface, array): PromiseInterface
19
-     */
20
-    private $nextHandler;
21
-    /**
22
-     * @var callable
23
-     */
24
-    private $decider;
25
-    /**
26
-     * @var callable(int)
27
-     */
28
-    private $delay;
29
-    /**
30
-     * @param callable                                            $decider     Function that accepts the number of retries,
31
-     *                                                                         a request, [response], and [exception] and
32
-     *                                                                         returns true if the request is to be
33
-     *                                                                         retried.
34
-     * @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke.
35
-     * @param (callable(int): int)|null                           $delay       Function that accepts the number of retries
36
-     *                                                                         and returns the number of
37
-     *                                                                         milliseconds to delay.
38
-     */
39
-    public function __construct(callable $decider, callable $nextHandler, callable $delay = null)
40
-    {
41
-        $this->decider = $decider;
42
-        $this->nextHandler = $nextHandler;
43
-        $this->delay = $delay ?: __CLASS__ . '::exponentialDelay';
44
-    }
45
-    /**
46
-     * Default exponential backoff delay function.
47
-     *
48
-     * @return int milliseconds.
49
-     */
50
-    public static function exponentialDelay(int $retries) : int
51
-    {
52
-        return (int) 2 ** ($retries - 1) * 1000;
53
-    }
54
-    public function __invoke(RequestInterface $request, array $options) : PromiseInterface
55
-    {
56
-        if (!isset($options['retries'])) {
57
-            $options['retries'] = 0;
58
-        }
59
-        $fn = $this->nextHandler;
60
-        return $fn($request, $options)->then($this->onFulfilled($request, $options), $this->onRejected($request, $options));
61
-    }
62
-    /**
63
-     * Execute fulfilled closure
64
-     */
65
-    private function onFulfilled(RequestInterface $request, array $options) : callable
66
-    {
67
-        return function ($value) use($request, $options) {
68
-            if (!($this->decider)($options['retries'], $request, $value, null)) {
69
-                return $value;
70
-            }
71
-            return $this->doRetry($request, $options, $value);
72
-        };
73
-    }
74
-    /**
75
-     * Execute rejected closure
76
-     */
77
-    private function onRejected(RequestInterface $req, array $options) : callable
78
-    {
79
-        return function ($reason) use($req, $options) {
80
-            if (!($this->decider)($options['retries'], $req, null, $reason)) {
81
-                return P\Create::rejectionFor($reason);
82
-            }
83
-            return $this->doRetry($req, $options);
84
-        };
85
-    }
86
-    private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null) : PromiseInterface
87
-    {
88
-        $options['delay'] = ($this->delay)(++$options['retries'], $response, $request);
89
-        return $this($request, $options);
90
-    }
17
+	/**
18
+	 * @var callable(RequestInterface, array): PromiseInterface
19
+	 */
20
+	private $nextHandler;
21
+	/**
22
+	 * @var callable
23
+	 */
24
+	private $decider;
25
+	/**
26
+	 * @var callable(int)
27
+	 */
28
+	private $delay;
29
+	/**
30
+	 * @param callable                                            $decider     Function that accepts the number of retries,
31
+	 *                                                                         a request, [response], and [exception] and
32
+	 *                                                                         returns true if the request is to be
33
+	 *                                                                         retried.
34
+	 * @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke.
35
+	 * @param (callable(int): int)|null                           $delay       Function that accepts the number of retries
36
+	 *                                                                         and returns the number of
37
+	 *                                                                         milliseconds to delay.
38
+	 */
39
+	public function __construct(callable $decider, callable $nextHandler, callable $delay = null)
40
+	{
41
+		$this->decider = $decider;
42
+		$this->nextHandler = $nextHandler;
43
+		$this->delay = $delay ?: __CLASS__ . '::exponentialDelay';
44
+	}
45
+	/**
46
+	 * Default exponential backoff delay function.
47
+	 *
48
+	 * @return int milliseconds.
49
+	 */
50
+	public static function exponentialDelay(int $retries) : int
51
+	{
52
+		return (int) 2 ** ($retries - 1) * 1000;
53
+	}
54
+	public function __invoke(RequestInterface $request, array $options) : PromiseInterface
55
+	{
56
+		if (!isset($options['retries'])) {
57
+			$options['retries'] = 0;
58
+		}
59
+		$fn = $this->nextHandler;
60
+		return $fn($request, $options)->then($this->onFulfilled($request, $options), $this->onRejected($request, $options));
61
+	}
62
+	/**
63
+	 * Execute fulfilled closure
64
+	 */
65
+	private function onFulfilled(RequestInterface $request, array $options) : callable
66
+	{
67
+		return function ($value) use($request, $options) {
68
+			if (!($this->decider)($options['retries'], $request, $value, null)) {
69
+				return $value;
70
+			}
71
+			return $this->doRetry($request, $options, $value);
72
+		};
73
+	}
74
+	/**
75
+	 * Execute rejected closure
76
+	 */
77
+	private function onRejected(RequestInterface $req, array $options) : callable
78
+	{
79
+		return function ($reason) use($req, $options) {
80
+			if (!($this->decider)($options['retries'], $req, null, $reason)) {
81
+				return P\Create::rejectionFor($reason);
82
+			}
83
+			return $this->doRetry($req, $options);
84
+		};
85
+	}
86
+	private function doRetry(RequestInterface $request, array $options, ResponseInterface $response = null) : PromiseInterface
87
+	{
88
+		$options['delay'] = ($this->delay)(++$options['retries'], $response, $request);
89
+		return $this($request, $options);
90
+	}
91 91
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $this->decider = $decider;
42 42
         $this->nextHandler = $nextHandler;
43
-        $this->delay = $delay ?: __CLASS__ . '::exponentialDelay';
43
+        $this->delay = $delay ?: __CLASS__.'::exponentialDelay';
44 44
     }
45 45
     /**
46 46
      * Default exponential backoff delay function.
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public static function exponentialDelay(int $retries) : int
51 51
     {
52
-        return (int) 2 ** ($retries - 1) * 1000;
52
+        return (int)2 ** ($retries - 1) * 1000;
53 53
     }
54 54
     public function __invoke(RequestInterface $request, array $options) : PromiseInterface
55 55
     {
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
      */
65 65
     private function onFulfilled(RequestInterface $request, array $options) : callable
66 66
     {
67
-        return function ($value) use($request, $options) {
67
+        return function($value) use($request, $options) {
68 68
             if (!($this->decider)($options['retries'], $request, $value, null)) {
69 69
                 return $value;
70 70
             }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     private function onRejected(RequestInterface $req, array $options) : callable
78 78
     {
79
-        return function ($reason) use($req, $options) {
79
+        return function($reason) use($req, $options) {
80 80
             if (!($this->decider)($options['retries'], $req, null, $reason)) {
81 81
                 return P\Create::rejectionFor($reason);
82 82
             }
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/MessageFormatterInterface.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@
 block discarded – undo
5 5
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\RequestInterface;
6 6
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface;
7 7
 
8
-interface MessageFormatterInterface
9
-{
8
+interface MessageFormatterInterface {
10 9
     /**
11 10
      * Returns a formatted message string.
12 11
      *
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,12 +6,12 @@
 block discarded – undo
6 6
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\ResponseInterface;
7 7
 interface MessageFormatterInterface
8 8
 {
9
-    /**
10
-     * Returns a formatted message string.
11
-     *
12
-     * @param RequestInterface       $request  Request that was sent
13
-     * @param ResponseInterface|null $response Response that was received
14
-     * @param \Throwable|null        $error    Exception that was received
15
-     */
16
-    public function format(RequestInterface $request, ResponseInterface $response = null, \Throwable $error = null) : string;
9
+	/**
10
+	 * Returns a formatted message string.
11
+	 *
12
+	 * @param RequestInterface       $request  Request that was sent
13
+	 * @param ResponseInterface|null $response Response that was received
14
+	 * @param \Throwable|null        $error    Exception that was received
15
+	 */
16
+	public function format(RequestInterface $request, ResponseInterface $response = null, \Throwable $error = null) : string;
17 17
 }
Please login to merge, or discard this patch.