From 0723e9f01fe9950d9c0cc1bb9005771978086f48 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 3 Feb 2026 18:43:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(php):=20=E6=B7=BB=E5=8A=A0=E5=AF=B9?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E5=8F=82=E6=95=B0=E5=92=8C=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=9A=84=E9=94=99=E8=AF=AF=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在参数解析过程中添加了对引用参数(byRef)的支持检查 - 在函数调用中添加了对命名参数的支持检查 - 当遇到引用参数时抛出致命错误 - 当遇到命名参数时抛出致命错误 - 更新示例文件以注释相关测试代码 --- examples/ref.php | 28 ++++++++++++++++++++++------ src/Php/CompilerBase.php | 9 +++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/examples/ref.php b/examples/ref.php index 264cdc21..d867f412 100644 --- a/examples/ref.php +++ b/examples/ref.php @@ -1,11 +1,27 @@ stubFile and !$param->type) { throw new \RuntimeException('No type for ' . $this->parseIdentifier($param->var)); } + if ($param->byRef) { + $this->fatalError($param, 'ByRef parameters are not supported'); + } $name = $this->parseIdentifier($param->var); $type = $this->parseParameterType($param, $name); $list[] = $type . ' ' . $name; @@ -1790,6 +1793,9 @@ class CompilerBase extends \PhpAot\Core\Translator { $list_args = []; foreach ($args as $i => $arg) { + if ($arg->name !== null) { + $this->fatalError($arg, 'Named arguments are not supported'); + } $argInfo = $this->getArgInfo($arg, $nativeFunc, $i); $list_args[] = $this->getTypeConvertedArg($arg, $argInfo); } @@ -1807,6 +1813,9 @@ class CompilerBase extends \PhpAot\Core\Translator $list_args = []; foreach ($args as $i => $arg) { + if ($arg->name !== null) { + $this->fatalError($arg, 'Named arguments are not supported'); + } if ($this->isVarExpr($arg->value)) { $name = $this->parseIdentifier($arg->value); // 调用了不存在的变量,可能是引用