fix(php): 修复代码格式化和常量定义问题

- 将 $formatCode 默认值从 false 修改为 true 以启用代码格式化
- 在 README.md 中添加预览版系统兼容性说明
- 修复 README.md 中编译命令的路径描述错误
- 修复常量定义时 genCharPtr 方法调用参数缺失问题
pull/1/head
韩天峰 4 months ago
parent 00a8ea180b
commit db3dc030f0
  1. 4
      README.md
  2. 2
      src/Php/CompilerBase.php
  3. 2
      src/Php/Translator.php

@ -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
```

@ -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;

@ -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) {

Loading…
Cancel
Save