Skip to content

Commit 21e3f4c

Browse files
authored
Merge pull request #2 from stof/league_uri
Remove usage of deprecated league/uri APIs
2 parents f08fc78 + 599c36c commit 21e3f4c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
},
2121
"require": {
2222
"php": ">=8.1",
23-
"league/uri": "^7.4",
24-
"league/uri-interfaces": "^7.4"
23+
"league/uri": "^7.6",
24+
"league/uri-interfaces": "^7.6"
2525
},
2626
"require-dev": {
2727
"phpstan/phpstan": "^2.0",

src/Util.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace SourceSpan;
44

5-
use League\Uri\BaseUri;
65
use League\Uri\Contracts\UriInterface;
6+
use League\Uri\Uri;
77

88
/**
99
* @internal
@@ -349,10 +349,14 @@ public static function prettyUri(string|UriInterface $path): string
349349

350350
private static function pathFromUri(UriInterface $uri): string
351351
{
352+
if (!$uri instanceof Uri) {
353+
$uri = Uri::new($uri);
354+
}
355+
352356
if (\DIRECTORY_SEPARATOR === '\\') {
353-
return BaseUri::from($uri)->windowsPath() ?? throw new \InvalidArgumentException("Uri $uri must have scheme 'file:'.");
357+
return $uri->toWindowsPath() ?? throw new \InvalidArgumentException("Uri $uri must have scheme 'file:'.");
354358
}
355359

356-
return BaseUri::from($uri)->unixPath() ?? throw new \InvalidArgumentException("Uri $uri must have scheme 'file:'.");
360+
return $uri->toUnixPath() ?? throw new \InvalidArgumentException("Uri $uri must have scheme 'file:'.");
357361
}
358362
}

0 commit comments

Comments
 (0)