From 9b94b287cb2e314eeffb13335fee0e9426c6620f Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Thu, 22 Jan 2026 17:07:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20=E7=A7=BB=E9=99=A4=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E8=B5=8B=E5=80=BC=E8=A7=A3=E6=9E=90=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E5=AF=B9=E8=B1=A1=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除了 Expr_PropertyFetch 类型的属性赋值解析逻辑 - 在 Test 类中添加构造函数以简化对象初始化 - 更新示例代码使用构造函数进行对象创建和属性赋值 --- examples/obj.php | 10 +++++++--- src/Php/CompilerBase.php | 2 -- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/examples/obj.php b/examples/obj.php index 8b6e787a..b3890232 100644 --- a/examples/obj.php +++ b/examples/obj.php @@ -5,6 +5,12 @@ class Test public int $a; public int $b; + public function __construct(int $a, int $b) + { + $this->a = $a; + $this->b = $b; + } + public function test() { return $this->a + $this->b; @@ -13,9 +19,7 @@ class Test function main() { - $obj = new Test(); - $obj->a = 1; - $obj->b = 2; + $obj = new Test(1, 2); $arr = array(); $arr['obj'] = $obj; diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index fd382b53..3cf3ff7d 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -772,8 +772,6 @@ class CompilerBase extends \PhpAot\Core\Translator if ($left->getType() === self::EXPR_ARRAY_DIM_FETCH) { return $this->parseAssignArrayDim($left, $right); - } elseif ($left->getType() === 'Expr_PropertyFetch') { - return $this->parseAssignPropertyFetch($left, $right); } elseif ($left->getType() === 'Expr_StaticPropertyFetch') { $class = $this->identifierToStr($left->class); $propName = $this->identifierToStr($left->name);