test(stdlib): 添加新标准库函数测试用例

- 测试 gettype 函数对不同数据类型的返回值
- 验证 ucfirst 函数首字母大写功能
- 检查 floor 和 ceil 数学函数的正确性
- 测试 max 和 min 函数的数值比较功能
- 验证 uniqid 函数生成唯一标识符的能力
- 测试
pull/1/head
韩天峰 3 months ago
parent 71cd8daad1
commit 17e1035e21
  1. 8
      src/Php/CompilerBase.php
  2. 10
      src/Php/Translator.php
  3. 2
      src/Php/UniversalMethodCall.php

@ -216,6 +216,14 @@ class CompilerBase extends \PhpAot\Core\Translator
'phpx_big_float.h',
'phpx_decimal.h',
'php_aot_helper.h',
'php_std_core.h',
'php_std_url.h',
'php_std_string.h',
'php_std_misc.h',
'php_std_array.h',
'php_std_datetime.h',
'php_std_fs.h',
'php_std_math.h',
];
protected array $localHeaders = [];
protected array $internalFunctions = [];

@ -972,6 +972,16 @@ CODE;
// 生成扩展模块的源文件
$sourceFiles[] = $this->genExtension();
// stdlib: 直接 C++ 包装的 Zend 内置函数
$sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_core.cpp';
$sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_array.cpp';
$sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_string.cpp';
$sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_url.cpp';
$sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_datetime.cpp';
$sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_fs.cpp';
$sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_math.cpp';
$sourceFiles[] = $this->getPhpxDir() . '/src/misc/php_std_misc.cpp';
// embed 需要 main 函数,以及 cli 的内置函数定义
if ($this->isBuildModeBin()) {
$sourceFiles[] = $this->getPhpxDir() . '/src/misc/main.cc';

@ -90,7 +90,7 @@ trait UniversalMethodCall
'trim' => ['handler' => 'php_fn', 'fn' => 'trim', 'return_type' => CompilerBase::TYPE_STR, 'min_args' => 0, 'max_args' => 2],
'lTrim' => ['handler' => 'php_fn', 'fn' => 'ltrim', 'return_type' => CompilerBase::TYPE_STR, 'min_args' => 0, 'max_args' => 1],
'rTrim' => ['handler' => 'php_fn', 'fn' => 'rtrim', 'return_type' => CompilerBase::TYPE_STR, 'min_args' => 0, 'max_args' => 1],
'parseStr' => ['handler' => 'cpp_fn', 'fn' => 'php::fn::parse_str', 'return_type' => CompilerBase::TYPE_ARRAY, 'min_args' => 0, 'max_args' => 0],
'parseStr' => ['handler' => 'cpp_fn', 'fn' => 'php::std::parse_str', 'return_type' => CompilerBase::TYPE_ARRAY, 'min_args' => 0, 'max_args' => 0],
'parseUrl' => ['handler' => 'php_fn', 'fn' => 'parse_url', 'return_type' => CompilerBase::TYPE_VAR, 'min_args' => 0, 'max_args' => 1],
'contains' => ['handler' => 'php_fn', 'fn' => 'str_contains', 'return_type' => CompilerBase::TYPE_BOOL, 'min_args' => 1, 'max_args' => 1],
'incr' => ['handler' => 'php_fn', 'fn' => 'str_increment', 'return_type' => CompilerBase::TYPE_STR, 'min_args' => 0, 'max_args' => 0],

Loading…
Cancel
Save