From 9499aac1423a190409629b0f64458d2e54605d52 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Fri, 23 Jan 2026 14:22:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20=E6=9B=B4=E6=96=B0PHP=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=99=A8=E4=B8=AD=E7=9A=84=E7=B1=BB=E5=9E=8B=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E5=87=BD=E6=95=B0=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将php::to_int重命名为php::toInt以符合驼峰命名规范 - 将php::to_float重命名为php::toFloat以符合驼峰命名规范 - 将php::to_string重命名为php::toString以符合驼峰命名规范 - 将php::to_object重命名为php::toObject以符合驼峰命名规范 - 将php::to_array重命名为php::toArray以符合驼峰命名规范 - 将php::to_bool重命名为php::toBool以符合驼峰命名规范 - 移除examples/ns.cc文件中的测试代码 --- examples/ns.cc | 10 ---------- src/Php/CompilerBase.php | 26 +++++++++++++------------- 2 files changed, 13 insertions(+), 23 deletions(-) delete mode 100644 examples/ns.cc diff --git a/examples/ns.cc b/examples/ns.cc deleted file mode 100644 index 765472d1..00000000 --- a/examples/ns.cc +++ /dev/null @@ -1,10 +0,0 @@ -#include -#include -#include - -using namespace php; - -Int php_test(Int a, Var b, Str c, Array d) { - php_var_dump(d, 10); - return 0; -} \ No newline at end of file diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 312b60cf..e456eb2f 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1726,16 +1726,16 @@ class CompilerBase extends \PhpAot\Core\Translator protected function convertIntExpr(string $expr): string { - if (!$this->isClosedCall($expr, 'php::to_int')) { - return 'php::to_int(' . $this->trimBrackets($expr) . ')'; + if (!$this->isClosedCall($expr, 'php::toInt')) { + return 'php::toInt(' . $this->trimBrackets($expr) . ')'; } return $expr; } protected function convertFloatExpr(string $expr): string { - if (!$this->isClosedCall($expr, 'php::to_float')) { - return 'php::to_float(' . $this->trimBrackets($expr) . ')'; + if (!$this->isClosedCall($expr, 'php::toFloat')) { + return 'php::toFloat(' . $this->trimBrackets($expr) . ')'; } return $expr; } @@ -1748,19 +1748,19 @@ class CompilerBase extends \PhpAot\Core\Translator protected function convertStringExpr(string $expr): string { - if (!$this->isClosedCall($expr, 'php::to_string')) { - return 'php::to_string(' . $this->trimBrackets($expr) . ')'; + if (!$this->isClosedCall($expr, 'php::toString')) { + return 'php::toString(' . $this->trimBrackets($expr) . ')'; } return $expr; } protected function convertObjectExpr(string $expr, string $class = ''): string { - if (!$this->isClosedCall($expr, 'php::to_object')) { + if (!$this->isClosedCall($expr, 'php::toObject')) { if ($class === '') { - return 'php::to_object(' . $this->trimBrackets($expr) . ')'; + return 'php::toObject(' . $this->trimBrackets($expr) . ')'; } else { - return 'php::to_object(' . $this->trimBrackets($expr) . ', ' . $class . ')'; + return 'php::toObject(' . $this->trimBrackets($expr) . ', ' . $class . ')'; } } return $expr; @@ -1768,16 +1768,16 @@ class CompilerBase extends \PhpAot\Core\Translator protected function convertArrayExpr(string $expr): string { - if (!$this->isClosedCall($expr, 'php::to_array')) { - return 'php::to_array(' . $this->trimBrackets($expr) . ')'; + if (!$this->isClosedCall($expr, 'php::toArray')) { + return 'php::toArray(' . $this->trimBrackets($expr) . ')'; } return $expr; } protected function convertBoolExpr(string $expr): string { - if (!$this->isClosedCall($expr, 'php::to_bool')) { - return 'php::to_bool(' . $this->trimBrackets($expr) . ')'; + if (!$this->isClosedCall($expr, 'php::toBool')) { + return 'php::toBool(' . $this->trimBrackets($expr) . ')'; } return $expr; }