refactor(php): 更新PHP编译器中的类型转换函数命名

- 将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文件中的测试代码
pull/1/head
韩天峰 7 months ago
parent 58f9cb4c28
commit 9499aac142
  1. 10
      examples/ns.cc
  2. 26
      src/Php/CompilerBase.php

@ -1,10 +0,0 @@
#include <phpx.h>
#include <phpx_func.h>
#include <php_func_decl.h>
using namespace php;
Int php_test(Int a, Var b, Str c, Array d) {
php_var_dump(d, 10);
return 0;
}

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

Loading…
Cancel
Save