From 7b52412f825080bf2eadfb4829512201069ab396 Mon Sep 17 00:00:00 2001 From: tianfenghan Date: Wed, 8 Jul 2026 11:27:27 +0800 Subject: [PATCH] fix: remove ref reset on unset --- src/Php/CompilerBase.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index fe160707..c85c726b 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -5087,12 +5087,6 @@ class CompilerBase extends \PhpAot\Core\Translator implements PropertyAccessCont $type = $this->getVarType($name); if ($this->isNativeType($type)) { $this->warning($var, "Variable of native type `\${$name}` cannot be unset"); - } elseif ($type === self::TYPE_REF) { - // Reinitialize as a fresh empty Ref so subsequent writes - // to this variable don't access freed memory. - // Do NOT change localVars type — it must stay TYPE_REF - // for foreach-by-ref to work correctly. - $lines[] = $name . ' = ' . self::TYPE_REF . '();'; } else { $lines[] = "{$name}.unset();"; }