From 6878ecc51771f056b49624a8edbc55ce569f2ca7 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Tue, 27 Jan 2026 13:05:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20=E6=9B=B4=E6=96=B0=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E7=BB=B4=E5=BA=A6=E8=8E=B7=E5=8F=96=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=BB=A5=E6=94=AF=E6=8C=81=E5=86=99=E5=85=A5=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 parseArrayDimFetch 方法签名以接受写入布尔参数 - 在 offsetGetIndirect 调用中传递写入操作标识 - 为数组维度访问增加赋值表达式上下文支持 --- src/Php/CompilerBase.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index a150343a..0d4df23a 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -653,7 +653,7 @@ class CompilerBase extends \PhpAot\Core\Translator case 'Expr_Array': return $this->parseArray($expr); case self::EXPR_ARRAY_DIM_FETCH: - return $this->parseArrayDimFetch($expr); + return $this->parseArrayDimFetch($expr, $this->inAssignExpr); case 'Expr_PropertyFetch': return $this->parsePropertyFetch($expr, $this->inAssignExpr); case 'Expr_BinaryOp_ShiftLeft': @@ -1437,14 +1437,14 @@ class CompilerBase extends \PhpAot\Core\Translator } } - protected function parseArrayDimFetch($node): string + protected function parseArrayDimFetch($node, bool $write): string { $var = $this->parseIdentifier($node->var); if ($node->dim === null) { $this->fatalError($node, 'Unsupported operand types: null + array'); } $dim = $this->parseIdentifier($node->dim); - return $var . '.offsetGetIndirect(' . $this->trimBrackets($dim) . ')'; + return $var . '.offsetGetIndirect(' . $this->trimBrackets($dim) . ', ' . $this->escapeBool($write) . ')'; } protected function parseArrayDimStore($array, $dim, $var): string