From 599c36c51bf397c3da5bc338fe83431b9ae10ab6 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 21 Nov 2025 17:07:17 +0100 Subject: [PATCH] Remove usage of deprecated league/uri APIs --- composer.json | 4 ++-- src/Util.php | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index d76e32f..2877811 100644 --- a/composer.json +++ b/composer.json @@ -20,8 +20,8 @@ }, "require": { "php": ">=8.1", - "league/uri": "^7.4", - "league/uri-interfaces": "^7.4" + "league/uri": "^7.6", + "league/uri-interfaces": "^7.6" }, "require-dev": { "phpstan/phpstan": "^2.0", diff --git a/src/Util.php b/src/Util.php index ccddb00..2dc18b5 100644 --- a/src/Util.php +++ b/src/Util.php @@ -2,8 +2,8 @@ namespace SourceSpan; -use League\Uri\BaseUri; use League\Uri\Contracts\UriInterface; +use League\Uri\Uri; /** * @internal @@ -349,10 +349,14 @@ public static function prettyUri(string|UriInterface $path): string private static function pathFromUri(UriInterface $uri): string { + if (!$uri instanceof Uri) { + $uri = Uri::new($uri); + } + if (\DIRECTORY_SEPARATOR === '\\') { - return BaseUri::from($uri)->windowsPath() ?? throw new \InvalidArgumentException("Uri $uri must have scheme 'file:'."); + return $uri->toWindowsPath() ?? throw new \InvalidArgumentException("Uri $uri must have scheme 'file:'."); } - return BaseUri::from($uri)->unixPath() ?? throw new \InvalidArgumentException("Uri $uri must have scheme 'file:'."); + return $uri->toUnixPath() ?? throw new \InvalidArgumentException("Uri $uri must have scheme 'file:'."); } }