fix: remove ref reset on unset

pull/14/head
韩天峰 2 months ago
parent 254e1607b5
commit 7b52412f82
  1. 6
      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();";
}

Loading…
Cancel
Save