| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | +declare (strict_types=1); | |
| 3 | 4 | namespace Dudlewebs\WPMCS\s3\GuzzleHttp\Psr7; |
| 4 | 5 | |
| 5 | 6 | use Dudlewebs\WPMCS\s3\Psr\Http\Message\UriInterface; |
| 6 | 7 | /** |
| @@ -7,9 +8,9 @@ | ||
| 7 | 8 | * Resolves a URI reference in the context of a base URI and the opposite way. |
| 8 | 9 | * |
| 9 | 10 | * @author Tobias Schultze |
| 10 | 11 | * |
| 11 | - * @link https://tools.ietf.org/html/rfc3986#section-5 | |
| 12 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5 | |
| 12 | 13 | */ |
| 13 | 14 | final class UriResolver |
| 14 | 15 | { |
| 15 | 16 | /** |
| @@ -14,15 +15,11 @@ | ||
| 14 | 15 | { |
| 15 | 16 | /** |
| 16 | 17 | * Removes dot segments from a path and returns the new path. |
| 17 | 18 | * |
| 18 | - * @param string $path | |
| 19 | - * | |
| 20 | - * @return string | |
| 21 | - * | |
| 22 | - * @link http://tools.ietf.org/html/rfc3986#section-5.2.4 | |
| 19 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4 | |
| 23 | 20 | */ |
| 24 | - public static function removeDotSegments($path) | |
| 21 | + public static function removeDotSegments(string $path) : string | |
| 25 | 22 | { |
| 26 | 23 | if ($path === '' || $path === '/') { |
| 27 | 24 | return $path; |
| 28 | 25 | } |
| @@ -48,16 +45,11 @@ | ||
| 48 | 45 | } |
| 49 | 46 | /** |
| 50 | 47 | * Converts the relative URI into a new URI that is resolved against the base URI. |
| 51 | 48 | * |
| 52 | - * @param UriInterface $base Base URI | |
| 53 | - * @param UriInterface $rel Relative URI | |
| 54 | - * | |
| 55 | - * @return UriInterface | |
| 56 | - * | |
| 57 | - * @link http://tools.ietf.org/html/rfc3986#section-5.2 | |
| 49 | + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2 | |
| 58 | 50 | */ |
| 59 | - public static function resolve(UriInterface $base, UriInterface $rel) | |
| 51 | + public static function resolve(UriInterface $base, UriInterface $rel) : UriInterface | |
| 60 | 52 | { |
| 61 | 53 | if ((string) $rel === '') { |
| 62 | 54 | // we can simply return the same base URI instance for this same-document reference |
| 63 | 55 | return $base; |
| @@ -114,15 +106,10 @@ | ||
| 114 | 106 | * This method also accepts a target that is already relative and will try to relativize it further. Only a |
| 115 | 107 | * relative-path reference will be returned as-is. |
| 116 | 108 | * |
| 117 | 109 | * echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well |
| 118 | - * | |
| 119 | - * @param UriInterface $base Base URI | |
| 120 | - * @param UriInterface $target Target URI | |
| 121 | - * | |
| 122 | - * @return UriInterface The relative URI reference | |
| 123 | 110 | */ |
| 124 | - public static function relativize(UriInterface $base, UriInterface $target) | |
| 111 | + public static function relativize(UriInterface $base, UriInterface $target) : UriInterface | |
| 125 | 112 | { |
| 126 | 113 | if ($target->getScheme() !== '' && ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '')) { |
| 127 | 114 | return $target; |
| 128 | 115 | } |
| @@ -149,14 +136,15 @@ | ||
| 149 | 136 | // If the base URI has a query but the target has none, we cannot return an empty path reference as it would |
| 150 | 137 | // inherit the base query component when resolving. |
| 151 | 138 | if ($target->getQuery() === '') { |
| 152 | 139 | $segments = \explode('/', $target->getPath()); |
| 140 | + /** @var string $lastSegment */ | |
| 153 | 141 | $lastSegment = \end($segments); |
| 154 | 142 | return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment); |
| 155 | 143 | } |
| 156 | 144 | return $emptyPathUri; |
| 157 | 145 | } |
| 158 | - private static function getRelativePath(UriInterface $base, UriInterface $target) | |
| 146 | + private static function getRelativePath(UriInterface $base, UriInterface $target) : string | |
| 159 | 147 | { |
| 160 | 148 | $sourceSegments = \explode('/', $base->getPath()); |
| 161 | 149 | $targetSegments = \explode('/', $target->getPath()); |
| 162 | 150 | \array_pop($sourceSegments); |