File tree Expand file tree Collapse file tree 2 files changed +26
-10
lines changed Expand file tree Collapse file tree 2 files changed +26
-10
lines changed Original file line number Diff line number Diff line change 44
55namespace Soap \Wsdl \Uri ;
66
7- use League \Uri \BaseUri ;
87use League \Uri \Modifier ;
8+ use League \Uri \Uri ;
9+ use function Psl \Str \starts_with ;
910
1011final class IncludePathBuilder
1112{
1213 public static function build (string $ relativePath , string $ fromFile ): string
1314 {
14- return Modifier::from (BaseUri::from ($ fromFile )->resolve ($ relativePath ))
15+ $ baseUri = match (true ) {
16+ starts_with ($ fromFile , '/ ' ) => Uri::fromUnixPath ($ fromFile ),
17+ default => Uri::new ($ fromFile ),
18+ };
19+
20+ $ resolvedUri = $ baseUri ->resolve ($ relativePath );
21+ $ modifier = Modifier::wrap ($ resolvedUri )
1522 ->removeDotSegments ()
16- ->removeEmptySegments ()
17- ->getUri ()
18- ->__toString ()
19- ;
23+ ->removeEmptySegments ();
24+
25+ /**
26+ * @var Uri $relativeUri
27+ * @psalm-suppress UndefinedClass PHP's URI classes are only available from PHP 8.5
28+ */
29+ $ relativeUri = $ modifier ->unwrap ();
30+
31+ if ($ relativeUri ->getScheme () === 'file ' ) {
32+ return $ relativeUri ->getPath ();
33+ }
34+
35+ return $ relativeUri ->toString ();
2036 }
2137}
Original file line number Diff line number Diff line change @@ -20,13 +20,13 @@ public static function provideBuildPaths()
2020 {
2121 yield 'same-dir-file ' => [
2222 'relativePath ' => 'otherfile.xml ' ,
23- 'fromFile ' => 'somedir/somefile.xml ' ,
24- 'expected ' => 'somedir/otherfile.xml ' ,
23+ 'fromFile ' => '/ somedir/somefile.xml ' ,
24+ 'expected ' => '/ somedir/otherfile.xml ' ,
2525 ];
2626 yield 'child-dir-file ' => [
2727 'relativePath ' => '../otherfile.xml ' ,
28- 'fromFile ' => 'somedir/child/somefile.xml ' ,
29- 'expected ' => 'somedir/otherfile.xml ' ,
28+ 'fromFile ' => '/ somedir/child/somefile.xml ' ,
29+ 'expected ' => '/ somedir/otherfile.xml ' ,
3030 ];
3131 yield 'http-file ' => [
3232 'relativePath ' => 'otherfile.xml ' ,
You can’t perform that action at this time.
0 commit comments