diff --git a/bin/gen_stub.php b/bin/gen_stub.php index 9f8ba4a7..9826d10c 100755 --- a/bin/gen_stub.php +++ b/bin/gen_stub.php @@ -4252,7 +4252,7 @@ class FileInfo { public bool $generateClassEntries = true; private bool $isUndocumentable = false; private bool $legacyArginfoGeneration = false; - private ?int $minimumPhpVersionIdCompatibility = null; + private ?int $minimumPhpVersionIdCompatibility = PHP_80_VERSION_ID; /** @param array $fileTags */ public function __construct(array $fileTags) { diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 94de34e9..352b1634 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -3595,19 +3595,12 @@ class CompilerBase extends \PhpAot\Core\Translator if ($this->getVarType($id) === self::TYPE_OBJECT) { return $id; } - if (isset($this->context->objectWrappers[$id])) { - return 'php_get_object_wrap(' . $this->context->objectWrappers[$id] . ', ' . $id . ')'; - } else { - $tmpVar = $this->genTmpVarName(); - $this->addLocalVar($tmpVar, self::TYPE_OBJECT); - $this->context->beforeStmtLines[] = $this->getIndent() . $tmpVar . ' = ' . $id . ';'; - $this->context->objectWrappers[$id] = $tmpVar; - return $tmpVar; + if (!isset($this->context->objectWrappers[$id])) { + $this->context->objectWrappers[$id] = $this->addTmpVar(self::TYPE_OBJECT); } + return 'php_get_object_wrap(' . $this->context->objectWrappers[$id] . ', ' . $id . ')'; } else { - $tmpVar = $this->genTmpVarName(); - $this->context->beforeStmtLines[] = $this->getIndent() . self::TYPE_OBJECT . ' ' . $tmpVar . ' = ' . $id . ';'; - return $tmpVar; + return self::TYPE_OBJECT . '(' . $id . ')'; } } diff --git a/src/Php/Generator/Utils.php b/src/Php/Generator/Utils.php index 0b3c107a..fb3aa1a3 100644 --- a/src/Php/Generator/Utils.php +++ b/src/Php/Generator/Utils.php @@ -30,7 +30,9 @@ trait Utils protected function escapeString(string $str): string { - return addcslashes($str, "\\\"\n\r\t\v\f\0\x01..\x1f\x7f..\xff"); + $str = addcslashes($str, "\\\"\n\r\t\v\f\0\x01..\x1f\x7f..\xff"); + // C++ trigraph + return str_replace('??', '\?\?', $str); } protected function escapeBool(bool $bool): string