From 40c7c27831b2b635a235292f9e5f78f8a2113e3c Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 12 Dec 2023 16:55:56 +0000 Subject: [PATCH 1/2] Merge pull request #1491 from hydephp/improve-phar-support Improve support for running HydePHP through the Phar archive https://github.com/hydephp/develop/commit/e361c3e0f78f77c1ea20305dd015b2fcc082c8f8 --- src/Foundation/Kernel/Filesystem.php | 4 ++++ src/Foundation/PharSupport.php | 7 +------ tests/Feature/Foundation/FilesystemTest.php | 5 +++++ tests/Feature/PharSupportTest.php | 11 ----------- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/Foundation/Kernel/Filesystem.php b/src/Foundation/Kernel/Filesystem.php index dcc8f79e..883663d3 100644 --- a/src/Foundation/Kernel/Filesystem.php +++ b/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/src/Foundation/PharSupport.php b/src/Foundation/PharSupport.php index 7f76b02f..7117df5b 100644 --- a/src/Foundation/PharSupport.php +++ b/src/Foundation/PharSupport.php @@ -6,7 +6,6 @@ use Hyde\Hyde; use Phar; -use BadMethodCallException; use function dirname; use function is_dir; @@ -47,10 +46,6 @@ public static function hasVendorDirectory(): bool public static function vendorPath(string $path = '', string $package = 'framework'): string { - if ($package !== 'framework') { - throw new BadMethodCallException('Cannot use vendorPath() outside of the framework package when running from a Phar archive.'); - } - - return rtrim(str_replace('/', DIRECTORY_SEPARATOR, rtrim(dirname(__DIR__, 2).'/'.$path, '/\\')), '/\\'); + return rtrim(str_replace('/', DIRECTORY_SEPARATOR, rtrim(dirname(__DIR__, 3).'/'.$package.'/'.$path, '/\\')), '/\\'); } } diff --git a/tests/Feature/Foundation/FilesystemTest.php b/tests/Feature/Foundation/FilesystemTest.php index 30400cee..a21c3ccd 100644 --- a/tests/Feature/Foundation/FilesystemTest.php +++ b/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')); diff --git a/tests/Feature/PharSupportTest.php b/tests/Feature/PharSupportTest.php index 8bca9b57..f6e46f32 100644 --- a/tests/Feature/PharSupportTest.php +++ b/tests/Feature/PharSupportTest.php @@ -4,7 +4,6 @@ namespace Hyde\Framework\Testing\Feature; -use BadMethodCallException; use Hyde\Foundation\PharSupport; use Hyde\Hyde; use Hyde\Testing\TestCase; @@ -65,16 +64,6 @@ public function test_vendor_path_can_run_in_phar_with_path_argument() $this->assertEquals($this->replaceSlashes(Hyde::path("{$this->getBaseVendorPath()}/framework/file.php")), Hyde::vendorPath('file.php')); } - public function test_vendor_path_can_run_in_phar_with_package_argument_but_throws() - { - PharSupport::mock('running', true); - PharSupport::mock('hasVendorDirectory', false); - - $this->expectException(BadMethodCallException::class); - - Hyde::vendorPath(package: 'realtime-compiler'); - } - protected function getBaseVendorPath(): string { // Monorepo support for symlinked packages directory From 761d59e33f9ee521a0444ded436aab300f78b226 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 12 Dec 2023 18:34:50 +0000 Subject: [PATCH 2/2] Merge pull request #1495 from hydephp/framework-v1.4.1 Framework version v1.4.1 https://github.com/hydephp/develop/commit/7e128474f3b6c20005ceaa5abd80468fd3407779 --- src/Foundation/HydeKernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Foundation/HydeKernel.php b/src/Foundation/HydeKernel.php index 3b65f666..b7c8205b 100644 --- a/src/Foundation/HydeKernel.php +++ b/src/Foundation/HydeKernel.php @@ -49,7 +49,7 @@ class HydeKernel implements SerializableContract use Serializable; use Macroable; - final public const VERSION = '1.4.0'; + final public const VERSION = '1.4.1'; protected static self $instance;