Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HydePHP v1.4.1 - 2023-12-12 #586

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Foundation/HydeKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions src/Foundation/Kernel/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions src/Foundation/PharSupport.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Hyde\Hyde;
use Phar;
use BadMethodCallException;

use function dirname;
use function is_dir;
Expand Down Expand Up @@ -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, '/\\')), '/\\');
}
}
5 changes: 5 additions & 0 deletions tests/Feature/Foundation/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
11 changes: 0 additions & 11 deletions tests/Feature/PharSupportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Hyde\Framework\Testing\Feature;

use BadMethodCallException;
use Hyde\Foundation\PharSupport;
use Hyde\Hyde;
use Hyde\Testing\TestCase;
Expand Down Expand Up @@ -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
Expand Down
Loading