From 81957f56d7d5bc39d316d9c4a3d0e4cf0350a514 Mon Sep 17 00:00:00 2001 From: rango Date: Thu, 30 Apr 2026 21:32:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(php):=20=E6=9B=B4=E6=96=B0=E7=AC=A6?= =?UTF-8?q?=E5=8F=B7=E5=B8=B8=E9=87=8F=E5=B9=B6=E6=B7=BB=E5=8A=A0=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=88=97=E8=A1=A8=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在Symbol类中添加argList方法返回'php::ArgList' - 修改CompilerBase中参数列表的返回值格式 - 添加count-array.php示例文件展示数组计数功能 --- examples/error/count-array.php | 30 ++++++++++++++++++++++++++++++ src/Php/CompilerBase.php | 2 +- src/Php/Symbol.php | 5 +++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 examples/error/count-array.php diff --git a/examples/error/count-array.php b/examples/error/count-array.php new file mode 100644 index 00000000..2810580a --- /dev/null +++ b/examples/error/count-array.php @@ -0,0 +1,30 @@ +array = $array; + } +} + +class Bar +{ + public function run(array $array) + { + $n = count($array); + var_dump($n); + } +} + +function main() +{ + $bar = new Bar(); + + $foo = new FooArray([1, 2, 3]); + + $bar->run($foo->array); + +} \ No newline at end of file diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 918889b7..cd92b7b4 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -3405,7 +3405,7 @@ class CompilerBase extends \PhpAot\Core\Translator $list_args[] = $this->parseArg($arg); } - return '{' . implode(', ', $list_args) . '}'; + return Symbol::argList() . '{' . implode(', ', $list_args) . '}'; } /** diff --git a/src/Php/Symbol.php b/src/Php/Symbol.php index df5d3200..f033520d 100644 --- a/src/Php/Symbol.php +++ b/src/Php/Symbol.php @@ -49,4 +49,9 @@ class Symbol { return 'php::getClassEntrySafe'; } + + public static function argList(): string + { + return 'php::ArgList'; + } }