From db3dc030f00c708235a8575a2df11051253f43ce Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 23 Apr 2026 15:19:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(php):=20=E4=BF=AE=E5=A4=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=92=8C=E5=B8=B8=E9=87=8F?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 $formatCode 默认值从 false 修改为 true 以启用代码格式化 - 在 README.md 中添加预览版系统兼容性说明 - 修复 README.md 中编译命令的路径描述错误 - 修复常量定义时 genCharPtr 方法调用参数缺失问题 --- README.md | 4 +++- src/Php/CompilerBase.php | 2 +- src/Php/Translator.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 44566d9a..c172fc4a 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ - 需要 GCC-9 以上版本,支持 C++17 标准 - 需要 CMake-3.24 以上版本 +> 预览版目前仅支持 `Linux` 系统,建议使用 `Ubuntu 22.04` + ## PHP 必须包含 embed 模块 @@ -11,7 +13,7 @@ 进入 `vendor/swoole/phpx` 目录,编译 `phpx` ```shell -vendor/swoole/phpx +cd vendor/swoole/phpx cmake . make -j32 ``` diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index f2f730d7..1092a3dc 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -158,7 +158,7 @@ class CompilerBase extends \PhpAot\Core\Translator protected string $ldflags = ''; protected int $floatPrecision = 17; protected bool $debugInfo = false; - protected bool $formatCode = false; + protected bool $formatCode = true; protected bool $printBacktraceOnError = false; protected bool $noLiteralStrings = false; protected string $file; diff --git a/src/Php/Translator.php b/src/Php/Translator.php index aeec5a92..c2ae1a36 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -484,7 +484,7 @@ CODE; $code .= '// register constants' . PHP_EOL; foreach ($this->constants as $name => $const) { $code .= "{$name} = {$const->value};\n"; - $code .= 'php::define(' . $this->genCharPtr($const->name) . ', ' . $name . ');' . PHP_EOL; + $code .= 'php::define(' . $this->genCharPtr($const->name, true) . ', ' . $name . ');' . PHP_EOL; } $code .= '// global vars ' . PHP_EOL; foreach ($this->globalVars as $name => $type) {