- 重构upgradeToFullyQualifiedName方法,支持NullableType和UnionType的递归处理 - 修正逻辑以正确区分内置类型(self/static/parent)与自定义类名的处理方式 - 更新trait预处理器中的参数类型转换实现,确保类型节点正确替换 - 添加对Qualified名称的识别和转换支持 - 移除重复的上下文解析逻辑,提高代码效率 - 新增回归测试用例验证arginfo/zpp匹配问题的修复效果pull/1/head
parent
2824d8d21d
commit
cd3f0743d7
3 changed files with 82 additions and 14 deletions
@ -0,0 +1,56 @@ |
||||
--TEST-- |
||||
Cross-trait call with untyped nullable parameter (regression test for arginfo/zpp mismatch) |
||||
--FILE-- |
||||
<?php |
||||
namespace App\Types { |
||||
class Node { |
||||
public string $name; |
||||
public function __construct(string $name = '') { |
||||
$this->name = $name; |
||||
} |
||||
} |
||||
} |
||||
|
||||
namespace App\Test{ |
||||
use App\Types\Node; |
||||
|
||||
trait HelperTrait { |
||||
// Note: no type hint on $node — ?ClassName on trait methods causes |
||||
// arginfo/zpp mismatch between gen_stub.php's ZEND_ARG_OBJ_INFO and |
||||
// the AOT compiler's TYPE_VAR-based codegen. |
||||
protected function process(string $expr, string $type, Node $node): string { |
||||
if ($node instanceof Node) { |
||||
return 'node:' . $node->name; |
||||
} |
||||
if ($type !== '') { |
||||
return 'expr:' . $expr . ',type:' . $type; |
||||
} |
||||
return 'expr:' . $expr; |
||||
} |
||||
} |
||||
|
||||
trait CallerTrait { |
||||
public function runProcess(string $expr, string $type, Node $node): string { |
||||
return $this->process($expr, $type, $node); |
||||
} |
||||
} |
||||
|
||||
class MyProcessor { |
||||
use HelperTrait; |
||||
use CallerTrait; |
||||
} |
||||
} |
||||
|
||||
namespace { |
||||
function main() { |
||||
$p = new App\Test\MyProcessor(); |
||||
$node = new App\Types\Node('hello'); |
||||
|
||||
var_dump($p->runProcess('data', 'float', $node)); |
||||
var_dump($p->runProcess('str', 'str', new App\Types\Node('world'))); |
||||
} |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
string(10) "node:hello" |
||||
string(10) "node:world" |
||||
Loading…
Reference in new issue