← All changes
|
includes/sdk/google/guzzlehttp/psr7/src/UriNormalizer.php
+16
-16
1.2.4
→
1.4.2
View file →
| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | declare (strict_types=1); |
| 4 | -namespace Dudlewebs\WPMCS\GuzzleHttp\Psr7; | |
| 4 | +namespace Dudlewebs\WPMCS\GCP\GuzzleHttp\Psr7; | |
| 5 | 5 | |
| 6 | -use Dudlewebs\WPMCS\Psr\Http\Message\UriInterface; | |
| 6 | +use Dudlewebs\WPMCS\GCP\Psr\Http\Message\UriInterface; | |
| 7 | 7 | /** |
| 8 | 8 | * Provides methods to normalize and compare URIs. |
| 9 | 9 | * |
| 10 | 10 | * @author Tobias Schultze |
| @@ -103,9 +103,9 @@ | ||
| 103 | 103 | * @param int $flags A bitmask of normalizations to apply, see constants |
| 104 | 104 | * |
| 105 | 105 | * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2 |
| 106 | 106 | */ |
| 107 | - public static function normalize(UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS): UriInterface | |
| 107 | + public static function normalize(UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS) : UriInterface | |
| 108 | 108 | { |
| 109 | 109 | if ($flags & self::CAPITALIZE_PERCENT_ENCODING) { |
| 110 | 110 | $uri = self::capitalizePercentEncoding($uri); |
| 111 | 111 | } |
| @@ -124,14 +124,14 @@ | ||
| 124 | 124 | if ($flags & self::REMOVE_DOT_SEGMENTS && !Uri::isRelativePathReference($uri)) { |
| 125 | 125 | $uri = $uri->withPath(UriResolver::removeDotSegments($uri->getPath())); |
| 126 | 126 | } |
| 127 | 127 | if ($flags & self::REMOVE_DUPLICATE_SLASHES) { |
| 128 | - $uri = $uri->withPath(preg_replace('#//++#', '/', $uri->getPath())); | |
| 128 | + $uri = $uri->withPath(\preg_replace('#//++#', '/', $uri->getPath())); | |
| 129 | 129 | } |
| 130 | 130 | if ($flags & self::SORT_QUERY_PARAMETERS && $uri->getQuery() !== '') { |
| 131 | - $queryKeyValues = explode('&', $uri->getQuery()); | |
| 132 | - sort($queryKeyValues); | |
| 133 | - $uri = $uri->withQuery(implode('&', $queryKeyValues)); | |
| 131 | + $queryKeyValues = \explode('&', $uri->getQuery()); | |
| 132 | + \sort($queryKeyValues); | |
| 133 | + $uri = $uri->withQuery(\implode('&', $queryKeyValues)); | |
| 134 | 134 | } |
| 135 | 135 | return $uri; |
| 136 | 136 | } |
| 137 | 137 | /** |
| @@ -147,27 +147,27 @@ | ||
| 147 | 147 | * @param int $normalizations A bitmask of normalizations to apply, see constants |
| 148 | 148 | * |
| 149 | 149 | * @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.1 |
| 150 | 150 | */ |
| 151 | - public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS): bool | |
| 151 | + public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS) : bool | |
| 152 | 152 | { |
| 153 | 153 | return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations); |
| 154 | 154 | } |
| 155 | - private static function capitalizePercentEncoding(UriInterface $uri): UriInterface | |
| 155 | + private static function capitalizePercentEncoding(UriInterface $uri) : UriInterface | |
| 156 | 156 | { |
| 157 | 157 | $regex = '/(?:%[A-Fa-f0-9]{2})++/'; |
| 158 | - $callback = function (array $match): string { | |
| 159 | - return strtoupper($match[0]); | |
| 158 | + $callback = function (array $match) : string { | |
| 159 | + return \strtoupper($match[0]); | |
| 160 | 160 | }; |
| 161 | - return $uri->withPath(preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(preg_replace_callback($regex, $callback, $uri->getQuery())); | |
| 161 | + return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery())); | |
| 162 | 162 | } |
| 163 | - private static function decodeUnreservedCharacters(UriInterface $uri): UriInterface | |
| 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 { | |
| 167 | - return rawurldecode($match[0]); | |
| 166 | + $callback = function (array $match) : string { | |
| 167 | + return \rawurldecode($match[0]); | |
| 168 | 168 | }; |
| 169 | - return $uri->withPath(preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(preg_replace_callback($regex, $callback, $uri->getQuery())); | |
| 169 | + return $uri->withPath(\preg_replace_callback($regex, $callback, $uri->getPath()))->withQuery(\preg_replace_callback($regex, $callback, $uri->getQuery())); | |
| 170 | 170 | } |
| 171 | 171 | private function __construct() |
| 172 | 172 | { |
| 173 | 173 | // cannot be instantiated |