adjust compiler text

This commit is contained in:
Km.Van
2026-07-14 10:46:25 +08:00
parent 0b39e8d9ed
commit 9fe322e386
3 changed files with 10 additions and 10 deletions
+3 -3
View File
@@ -125,11 +125,11 @@ final class Compiler
*/
private function getCodeViaFilePath(string $filePath): string
{
echo "Packing `{$filePath}`... ";
// echo "Packing `{$filePath}`... ";
$code = file_get_contents($filePath);
if (false === $code) {
echo "FAILED\n";
echo "[FAILED] {$filePath}\n";
return '';
}
@@ -140,7 +140,7 @@ final class Compiler
// 💡 Opt: Safely remove leading <?php tag via regex to avoid bugs caused by magic number 5
$code = preg_replace('/^<\\?php\\s*/i', '', $code);
echo "OK\n";
// echo "OK\n";
return $code . "\n";
}
+4 -4
View File
@@ -34,12 +34,12 @@ final class ScriptGeneration
public function generate(): void
{
// 验证源脚本文件是否存在 / Validate if the source script file exists
if ( ! is_file($this->scriptFilePath)) {
if ( !is_file($this->scriptFilePath)) {
throw new InvalidArgumentException("[ScriptGeneration] Source file not found: {$this->scriptFilePath}");
}
// 验证目标模板文件是否存在 / Validate if the destination file exists
if ( ! is_file($this->distFilePath)) {
if ( !is_file($this->distFilePath)) {
throw new InvalidArgumentException("[ScriptGeneration] Destination file not found: {$this->distFilePath}");
}
@@ -47,7 +47,7 @@ final class ScriptGeneration
$this->setScript($scriptContent);
echo "[ScriptGeneration] Script content written successfully.\n";
echo "[ScriptGeneration] Script content has been written successfully.\n";
}
/**
@@ -81,7 +81,7 @@ final class ScriptGeneration
// 检查是否存在占位符(可选优化:防止无效替换)
// Check if the placeholder exists (Optional optimization: prevent redundant writes)
if ( ! str_contains($distContent, '{{X_SCRIPT}}')) {
if ( !str_contains($distContent, '{{X_SCRIPT}}')) {
throw new RuntimeException('[ScriptGeneration] Placeholder {{X_SCRIPT}} not found in destination file.');
}
+3 -3
View File
@@ -30,13 +30,13 @@ final class StyleGeneration
{
// 校验源样式文件是否存在
// Validate if the source style file exists.
if ( ! is_file($this->styleFilePath)) {
if ( !is_file($this->styleFilePath)) {
throw new RuntimeException("[StyleGeneration] File not found: {$this->styleFilePath}");
}
// 校验目标文件是否存在
// Validate if the target dist file exists.
if ( ! is_file($this->distFilePath)) {
if ( !is_file($this->distFilePath)) {
throw new RuntimeException("[StyleGeneration] File not found: {$this->distFilePath}");
}
@@ -45,7 +45,7 @@ final class StyleGeneration
// 执行替换并写入文件
// Perform replacement and write to file.
if ($this->setStyle($styleContent)) {
echo "[StyleGeneration] Script content wrote successfully.\n";
echo "[StyleGeneration] Script content has been written successfully.\n";
} else {
throw new RuntimeException('[StyleGeneration] Error: Cannot write script content to dist.');
}