Skip to content

Commit

Permalink
Merge pull request #586 from hydephp/develop
Browse files Browse the repository at this point in the history
HydePHP v1.4.1 - 2023-12-12
  • Loading branch information
caendesilva authored Dec 12, 2023
2 parents dfd4075 + 761d59e commit ef717aa
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
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

0 comments on commit ef717aa

Please sign in to comment.