diff --git a/src/Php/Translator.php b/src/Php/Translator.php index dbb1ff9f..69fc3137 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -1252,6 +1252,7 @@ class Translator extends Preprocessor if ($functionDef->returnType !== self::TYPE_VOID) { $cppCode .= $this->getIndent() . 'auto retval = ' . $fn . '(' . $callParams . ');' . PHP_EOL; $cppCode .= $this->getIndent() . 'php::move(retval, return_value);' . PHP_EOL; + $cppCode .= $this->getIndent() . 'php::deref(return_value);' . PHP_EOL; } else { $cppCode .= $this->getIndent() . $fn . '(' . $callParams . ');' . PHP_EOL; } diff --git a/tests/aot/ref/009.phpt b/tests/aot/ref/009.phpt new file mode 100644 index 00000000..2b2ff674 --- /dev/null +++ b/tests/aot/ref/009.phpt @@ -0,0 +1,45 @@ +--TEST-- +class const 001 +--FILE-- +foo(); + } +} + +class WorkerB extends WorkerA +{ + public function foo(): array { + $list = [377, 64, 688, 2]; + $ref = &$list; + $this->sort($ref); + return $list; + } +} + +function main() +{ + $o = new WorkerB; + var_dump($o->run()); +} +?> +--EXPECT-- +array(4) { + [0]=> + int(2) + [1]=> + int(64) + [2]=> + int(377) + [3]=> + int(688) +} \ No newline at end of file