fix(compiler): 修复函数声明中的返回类型处理逻辑

- 在函数编译过程中添加了对返回类型的正确处理分支
- 确保当函数具有返回类型声明时不跳过必要的代码生成步骤
- 添加了测试用例验证可迭代类型声明的功能
- 修复了可能导致编译错误的条件判断逻辑
pull/1/head
韩天峰 5 months ago
parent 485dce7b95
commit 58b6d4fad4
  1. 2
      src/Php/CompilerBase.php
  2. 14
      tests/aot/type_decl/005.phpt

@ -837,6 +837,8 @@ class CompilerBase extends \PhpAot\Core\Translator
$this->climate->cyan('Skip function ' . $name);
}
$this->indentLevel--;
} else {
$stmts = $this->genReturnCode();
}
$functionDeclCode = $this->getReturnType() . ' ' . self::PREFIX . $name . '(';

@ -0,0 +1,14 @@
--TEST--
Type Declarations
--FILE--
<?php
function sum_iterable($numbers): mixed {
}
function main() {
sum_iterable([1, 2, 3, 4, 5]);
var_dump(__FUNCTION__);
}
?>
--EXPECT--
string(4) "main"
Loading…
Cancel
Save