From 1e22f19e63d683b835a9226c39b75deb310d7c0a Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Mon, 11 May 2026 18:30:50 +0800 Subject: [PATCH] =?UTF-8?q?refactor(php):=20stdArray=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=9C=A8=E5=A0=86=E4=B8=8A=E5=88=86=E9=85=8D=E5=86=85?= =?UTF-8?q?=E5=AD=98=EF=BC=8C=E9=81=BF=E5=85=8D=E6=A0=88=E5=86=85=E5=AD=98?= =?UTF-8?q?=E8=BF=87=E5=A4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Php/CompilerBase.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index ad9855cc..a579201c 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -5353,14 +5353,16 @@ class CompilerBase extends \PhpAot\Core\Translator $code .= $this->getIndent(); if ($type === self::TYPE_STD_ARRAY) { $info = $this->context->stdArrays[$name]; - $code .= $info['decl'] . ' ' . $name . '{}'; + $code .= "auto {$name}_unique_ptr = std::make_unique<{$info['decl']}>();\n"; + $code .= $this->getIndent() . ' auto &' . $name . ' = *' . $name . '_unique_ptr;'; } else { $code .= $type . ' ' . $name; if ($type === self::TYPE_INT or $type === self::TYPE_FLOAT or $type === self::TYPE_BOOL) { $code .= ' = 0'; } + $code .= ';'; } - $code .= ';' . PHP_EOL; + $code .= PHP_EOL; } foreach ($this->context->globalVars as $name => $type) { $code .= $this->getIndent() . self::TYPE_VAR . ' &' . $name . ' = ' . $this->escapeGlobalVar($name) . ';' . PHP_EOL;