From ed6019291324c058ed2a772f321a0c7227f9ecb1 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Tue, 12 Dec 2023 17:33:05 +0100 Subject: [PATCH] Update path helper to not format Phar paths This should resolve a lot of the issues we're having with the standalone, due to Phar paths being formatted like `'H:\monorepo/phar://foo'`, when they should be unchanged (`'phar://foo'`) --- packages/framework/src/Foundation/Kernel/Filesystem.php | 4 ++++ .../framework/tests/Feature/Foundation/FilesystemTest.php | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/packages/framework/src/Foundation/Kernel/Filesystem.php b/packages/framework/src/Foundation/Kernel/Filesystem.php index dcc8f79ed73..160cb940475 100644 --- a/packages/framework/src/Foundation/Kernel/Filesystem.php +++ b/packages/framework/src/Foundation/Kernel/Filesystem.php @@ -56,6 +56,10 @@ public function path(string $path = ''): string return $this->getBasePath(); } + if (str_starts_with($path, 'phar://') ) { + return $path; + } + $path = unslash($this->pathToRelative($path)); return path_join($this->getBasePath(), $path); diff --git a/packages/framework/tests/Feature/Foundation/FilesystemTest.php b/packages/framework/tests/Feature/Foundation/FilesystemTest.php index 30400cee8ff..a21c3ccd041 100644 --- a/packages/framework/tests/Feature/Foundation/FilesystemTest.php +++ b/packages/framework/tests/Feature/Foundation/FilesystemTest.php @@ -115,6 +115,11 @@ public function testPathMethodResolvesAlreadyAbsolutePathsUsingHelperWithTrailin $this->assertSame($this->filesystem->path('foo'), $this->filesystem->path($this->filesystem->path('foo/'))); } + public function testPathMethodDoesNotModifyPharPaths() + { + $this->assertSame('phar://foo', $this->filesystem->path('phar://foo')); + } + public function testHydePathMethodExists() { $this->assertTrue(method_exists(HydeKernel::class, 'path'));