diff --git a/bin/dump-ast.php b/bin/dump-ast.php index 631aa6f0..ea037169 100755 --- a/bin/dump-ast.php +++ b/bin/dump-ast.php @@ -126,10 +126,10 @@ function valueToArray(mixed $value): mixed return $value; } -// ─── 美化打印 ───────────────────────────────────────────── +// ─── Pretty printing ────────────────────────────────────── /** - * 用缩进打印 AST 结构,类似 json 的视觉风格 + * Print the AST structure with indentation, similar to JSON's visual style. */ function printAst(array $nodes, string $indent = ''): void { @@ -221,7 +221,7 @@ echo "━━━━━━━━━━━━━━━━━━━━━━━━ echo "AST_ROOT: Program (L1-" . count($stmts) . " statements)\n\n"; /** - * 简洁的分层输出 + * Concise hierarchical output. */ function dumpNode(NodeAbstract $node, int $depth = 0): void { diff --git a/bin/extractor.php b/bin/extractor.php index 683d6139..95f6ab26 100644 --- a/bin/extractor.php +++ b/bin/extractor.php @@ -1,7 +1,7 @@ false, 'pretty' => false, @@ -73,16 +73,16 @@ function extractorMain(array $argv): void } } - // 显示帮助 + // Show help if ($options['help'] || (empty($args) && !$options['batch'])) { showUsage(); exit(0); } - // 创建提取器 + // Create the extractor $extractor = new TypePhp\Extractor(); - // 批量模式 + // Batch mode if ($options['batch']) { $prefixes = !empty($args[0]) ? explode(',', $args[0]) : ['php_']; $files = []; @@ -101,7 +101,7 @@ function extractorMain(array $argv): void $functions = $extractor->extractFromFiles($files, $prefixes); - // 输出结果 + // Output the result $jsonFlags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES; if ($options['pretty']) { $jsonFlags |= JSON_PRETTY_PRINT; @@ -111,7 +111,7 @@ function extractorMain(array $argv): void exit(0); } - // 单文件模式 + // Single-file mode $filename = $args[0] ?? null; $prefixesStr = $args[1] ?? 'php_'; $output = $args[2] ?? null; @@ -122,14 +122,14 @@ function extractorMain(array $argv): void exit(1); } - // 解析前缀 + // Parse prefixes $prefixes = array_map('trim', explode(',', $prefixesStr)); try { - // 提取函数 + // Extract functions $functions = $extractor->extractFunctions($filename, $prefixes); - // 准备 JSON 输出 + // Prepare JSON output $jsonFlags = JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES; if ($options['pretty']) { $jsonFlags |= JSON_PRETTY_PRINT; @@ -137,7 +137,7 @@ function extractorMain(array $argv): void $json = json_encode($functions, $jsonFlags); - // 输出 + // Output if ($output) { file_put_contents($output, $json . "\n"); fprintf(STDERR, "\033[0;32m已保存到: %s\033[0m\n", $output);