diff --git a/composer.json b/composer.json
index 22a6e5a5..b280d242 100755
--- a/composer.json
+++ b/composer.json
@@ -42,13 +42,10 @@
"dev:fix": "php -dxdebug.mode=off ./vendor/bin/php-cs-fixer fix .",
"dev:precommit": "pre-commit install && pre-commit autoupdate",
"dev:tips": "[ ! -f catpaw.phar ] && echo '' || php catpaw.phar --tips",
- "download:psalm": "[ ! -f psalm.phar ] && wget https://github.com/vimeo/psalm/releases/latest/download/psalm.phar || echo ''",
"post-autoload-dump": [
- "@download:psalm",
"@dev:tips"
],
"post-create-project-cmd": [
- "@download:psalm",
"@dev:tips"
]
},
diff --git a/dev-gui-example.sh b/dev-gui-example.sh
index 769ad53a..bed92067 100755
--- a/dev-gui-example.sh
+++ b/dev-gui-example.sh
@@ -1,8 +1,8 @@
#!/bin/bash
-pushd src/lib/Gui/lib &&\
-go build -o main.so -buildmode=c-shared main.go &&\
-cpp -P ./main.h ./main.static.h &&\
-popd || exit
+# pushd src/lib/Gui/lib &&\
+# go build -o main.so -buildmode=c-shared main.go &&\
+# cpp -P ./main.h ./main.static.h &&\
+# popd || exit
php -dxdebug.mode=debug -dxdebug.start_with_request=yes -dphar.readonly=0 ./bin/start --libraries='./src/lib' --entry='./src/gui-example.php'
diff --git a/psalm.xml b/psalm.xml
deleted file mode 100644
index 76c896c2..00000000
--- a/psalm.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
diff --git a/src/gui-example.php b/src/gui-example.php
index c2051564..dba1a32d 100644
--- a/src/gui-example.php
+++ b/src/gui-example.php
@@ -1,5 +1,6 @@
$base
+ * @return FileName
+ */
+ public static function create(array $path):self {
+ return new self($path);
+ }
+
+ private bool $checkPhar = false;
+
+ /**
+ * @param array $path
+ */
+ private function __construct(private array $path) {
+ }
+
+ /**
+ * Given a `$path`, create a file name.
+ * @param array $path
+ * @return string
+ */
+ private static function asFileName(array $path):string {
+ $parts = [];
+ $count = count($path);
+ for ($index = 0; $index < $count; $index++) {
+ $pathName = $path[$index];
+ if ($index < $count - 1 && !str_ends_with($pathName, '/')) {
+ $pathName = "$pathName/";
+ }
+ $parts[] = $pathName;
+ }
+ return join($parts)?:'';
+ }
+
+ /**
+ * Lookup the file in in the `.phar` before falling back to the file system.
+ * @return self
+ */
+ public function withPhar(): self {
+ $this->checkPhar = true;
+ return $this;
+ }
+
+ public function __toString(): string {
+ if (isPhar()) {
+ $phar = Phar::running();
+ $localizedFileName = str_replace("$phar/", '', self::asFileName($this->path));
+
+ if ($this->checkPhar) {
+ $pharFileName = "$phar/$localizedFileName";
+ if (!file_exists($pharFileName)) {
+ return realpath($localizedFileName);
+ }
+ return $pharFileName;
+ }
+ return realpath($localizedFileName);
+ } else {
+ return realpath(self::asFileName($this->path));
+ }
+ }
+}
diff --git a/src/scripts/Core/functions.php b/src/scripts/Core/functions.php
index 16ff9eab..4b1f4715 100755
--- a/src/scripts/Core/functions.php
+++ b/src/scripts/Core/functions.php
@@ -349,20 +349,11 @@ function stop(string|Error $error) {
/**
* Given a `$path`, create a file name.
- * @param string ...$path
- * @return string
+ * @param string ...$path
+ * @return FileName
*/
-function asFileName(string ...$path):string {
- $parts = [];
- $count = count($path);
- for ($index = 0; $index < $count; $index++) {
- $pathName = $path[$index];
- if ($index < $count - 1 && !str_ends_with($pathName, '/')) {
- $pathName = "$pathName/";
- }
- $parts[] = $pathName;
- }
- return realpath(join($parts))?:'';
+function asFileName(string ...$path):FileName {
+ return FileName::create($path);
}
/**
@@ -372,7 +363,8 @@ function asFileName(string ...$path):string {
*/
function asPharFileName(string ...$path):string {
if (isPhar()) {
- $phar = Phar::running();
+ $phar = Phar::running();
+
$path = [$phar, ...$path];
$parts = [];
$count = count($path);