Skip to content

Commit 4c589fe

Browse files
committed
feat(phar): use Filesystem\real_path syntax
1 parent b5b14d6 commit 4c589fe

File tree

9 files changed

+19
-23
lines changed

9 files changed

+19
-23
lines changed

packages/console/src/Highlight/TempestConsoleLanguage/Injections/FileInjection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
use Tempest\Highlight\Injection;
99
use Tempest\Highlight\ParsedInjection;
1010
use Tempest\Highlight\Themes\TerminalStyle;
11+
use Tempest\Support\Filesystem;
1112

1213
use function Tempest\root_path;
13-
use function Tempest\Support\Filesystem\real_path;
1414
use function Tempest\Support\str;
1515

1616
final readonly class FileInjection implements Injection
@@ -22,9 +22,9 @@ public function parse(string $content, Highlighter $highlighter): ParsedInjectio
2222
pattern: '/(?<match>\<file=(?<quote>[\"\'])(?<file>.+)\k<quote>\s*\/?>)/',
2323
callback: function (array $matches) {
2424
$href = $matches['file'];
25-
$exists = real_path($href) !== null;
25+
$exists = Filesystem\real_path($href) !== null;
2626
$file = $exists
27-
? str(real_path($href))->replace('\\', '/')->stripStart(root_path())->stripStart('/')
27+
? str(Filesystem\real_path($href))->replace('\\', '/')->stripStart(root_path())->stripStart('/')
2828
: $href;
2929

3030
return TerminalStyle::UNDERLINE((string) $file);

packages/core/src/Commands/DiscoveryStatusCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
use Tempest\Core\DiscoveryCache;
1111
use Tempest\Core\DiscoveryCacheStrategy;
1212
use Tempest\Core\Kernel;
13+
use Tempest\Support\Filesystem;
1314

1415
use function Tempest\root_path;
15-
use function Tempest\Support\Filesystem\real_path;
1616
use function Tempest\Support\str;
1717

1818
if (class_exists(\Tempest\Console\ConsoleCommand::class, false)) {
@@ -63,7 +63,7 @@ public function __invoke(
6363
$this->console->writeln();
6464

6565
foreach ($this->kernel->discoveryLocations as $discoveryLocation) {
66-
$path = str(real_path($discoveryLocation->path))
66+
$path = str(Filesystem\real_path($discoveryLocation->path))
6767
->replaceStart(root_path(), '.')
6868
->toString();
6969

packages/core/src/DiscoveryConfig.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Tempest\Core;
44

5-
use function Tempest\Support\Filesystem\real_path;
5+
use Tempest\Support\Filesystem;
66

77
final class DiscoveryConfig
88
{
@@ -27,7 +27,7 @@ public function skipPaths(string ...$paths): self
2727
foreach ($paths as $path) {
2828
$path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path);
2929

30-
$realpath = real_path($path);
30+
$realpath = Filesystem\real_path($path);
3131

3232
if ($realpath === null) {
3333
continue;

packages/core/src/FrameworkKernel.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
use Tempest\EventBus\EventBus;
1919
use Tempest\Process\GenericProcessExecutor;
2020
use Tempest\Router\Exceptions\HttpExceptionHandler;
21-
22-
use function Tempest\Support\Filesystem\real_path;
21+
use Tempest\Support\Filesystem;
2322

2423
final class FrameworkKernel implements Kernel
2524
{
@@ -77,7 +76,7 @@ public static function boot(
7776

7877
public function validateRoot(): self
7978
{
80-
$root = real_path($this->root);
79+
$root = Filesystem\real_path($this->root);
8180

8281
if (! is_dir($root)) {
8382
throw new RuntimeException('The specified root directory is not valid.');
@@ -198,7 +197,7 @@ public function registerInternalStorage(): self
198197
throw CouldNotRegisterInternalStorage::noPermission($path);
199198
}
200199

201-
$this->internalStorage = real_path($path);
200+
$this->internalStorage = Filesystem\real_path($path);
202201

203202
return $this;
204203
}

packages/core/src/Kernel/LoadConfig.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
use Tempest\Core\ConfigCache;
99
use Tempest\Core\Kernel;
1010
use Tempest\Support\Arr\MutableArray;
11+
use Tempest\Support\Filesystem;
1112
use Tempest\Support\Str;
1213

13-
use function Tempest\Support\Filesystem\real_path;
14-
1514
/** @internal */
1615
final readonly class LoadConfig
1716
{
@@ -87,7 +86,7 @@ public function find(): array
8786
*/
8887
private function scan(string $path, MutableArray $configPaths): void
8988
{
90-
$input = real_path($path);
89+
$input = Filesystem\real_path($path);
9190

9291
// Make sure the path is valid
9392
if ($input === null) {

packages/core/src/Kernel/LoadDiscoveryClasses.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@
1616
use Tempest\Discovery\DiscoveryLocation;
1717
use Tempest\Discovery\SkipDiscovery;
1818
use Tempest\Reflection\ClassReflector;
19+
use Tempest\Support\Filesystem;
1920
use Throwable;
2021

21-
use function Tempest\Support\Filesystem\real_path;
22-
2322
/** @internal */
2423
final class LoadDiscoveryClasses
2524
{
@@ -107,7 +106,7 @@ private function discover(array $discoveries): void
107106
*/
108107
private function scan(DiscoveryLocation $location, array $discoveries, string $path): void
109108
{
110-
$input = real_path($path);
109+
$input = Filesystem\real_path($path);
111110

112111
// Make sure the path is valid
113112
if ($input === null) {

packages/discovery/src/DiscoveryLocation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Tempest\Discovery;
66

7-
use function Tempest\Support\Filesystem\real_path;
7+
use Tempest\Support\Filesystem;
88

99
final class DiscoveryLocation
1010
{
@@ -20,7 +20,7 @@ public function __construct(
2020
string $path,
2121
) {
2222
$this->namespace = $namespace;
23-
$this->path = real_path(rtrim($path, '\\/'));
23+
$this->path = Filesystem\real_path(rtrim($path, '\\/'));
2424
}
2525

2626
public function isVendor(): bool

packages/vite/src/TagsResolver/DevelopmentTagsResolver.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
use function Tempest\root_path;
1313
use function Tempest\Support\arr;
14-
use function Tempest\Support\Filesystem\real_path;
1514
use function Tempest\Support\str;
1615

1716
final readonly class DevelopmentTagsResolver implements TagsResolver
@@ -61,7 +60,7 @@ private function fileToAssetPath(string $file): string
6160
return str($file)
6261
->when(
6362
condition: fn ($file) => $file->startsWith('./'),
64-
callback: fn ($file) => str(real_path(root_path($file->toString()))),
63+
callback: fn ($file) => str(Filesystem\real_path(root_path($file->toString()))),
6564
)
6665
->replace('\\', '/') // `realpath` makes slashes backwards, so replacements below wouldn't work
6766
->replaceStart(root_path('public'), '')

packages/vite/src/TagsResolver/ManifestTagsResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Tempest\Vite\TagsResolver;
66

7+
use Tempest\Support\Filesystem;
78
use Tempest\Support\Json;
89
use Tempest\Vite\Exceptions\ManifestEntrypointWasNotFoundException;
910
use Tempest\Vite\Manifest\Chunk;
@@ -14,7 +15,6 @@
1415

1516
use function Tempest\root_path;
1617
use function Tempest\Support\arr;
17-
use function Tempest\Support\Filesystem\real_path;
1818
use function Tempest\Support\str;
1919
use function Tempest\Support\Str\ensure_starts_with;
2020

@@ -254,7 +254,7 @@ private function fileToAssetPath(string $file): string
254254
return str($file)
255255
->when(
256256
condition: fn ($file) => $file->startsWith('./'),
257-
callback: fn ($file) => str(real_path(root_path($file->toString()))),
257+
callback: fn ($file) => str(Filesystem\real_path(root_path($file->toString()))),
258258
)
259259
->replaceStart(root_path('public'), '')
260260
->replaceStart(root_path(), '')

0 commit comments

Comments
 (0)