- 将对象稳定性分析从属性提升优化中分离为独立方法 - 添加analyzeStableObjects方法用于分析方法分派的对象稳定性 - 修改optimizeObjectProps方法只在启用原生类型时执行属性提升 - 提取collectStableObjectCandidates辅助方法收集稳定对象候选者 - 更新翻译器中的优化执行顺序和条件判断逻辑 - 添加两个新的动态调用测试用例验证重pull/3/head
parent
8148ffce1e
commit
a7b5b248fb
4 changed files with 134 additions and 40 deletions
@ -0,0 +1,43 @@ |
||||
--TEST-- |
||||
call overridden method through namespaced parent type |
||||
--FILE-- |
||||
<?php |
||||
namespace Demo { |
||||
use native_types; |
||||
|
||||
class Base |
||||
{ |
||||
public function run(): string |
||||
{ |
||||
return 'base'; |
||||
} |
||||
} |
||||
|
||||
class Impl extends Base |
||||
{ |
||||
public function run(): string |
||||
{ |
||||
return 'impl'; |
||||
} |
||||
} |
||||
|
||||
function run(Base $obj): string |
||||
{ |
||||
$alias = $obj; |
||||
return $alias->run(); |
||||
} |
||||
} |
||||
|
||||
namespace { |
||||
use Demo\Impl; |
||||
|
||||
function main(): int |
||||
{ |
||||
$r = Demo\run(new Impl()); |
||||
echo "result: $r\n"; |
||||
return $r === 'impl' ? 0 : 1; |
||||
} |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
result: impl |
||||
@ -0,0 +1,35 @@ |
||||
--TEST-- |
||||
call overridden method through parent parameter type without native_types |
||||
--FILE-- |
||||
<?php |
||||
class Base |
||||
{ |
||||
public function run(): string |
||||
{ |
||||
return 'base'; |
||||
} |
||||
} |
||||
|
||||
class Impl extends Base |
||||
{ |
||||
public function run(): string |
||||
{ |
||||
return 'impl'; |
||||
} |
||||
} |
||||
|
||||
function run(Base $obj): string |
||||
{ |
||||
$alias = $obj; |
||||
return $alias->run(); |
||||
} |
||||
|
||||
function main(): int |
||||
{ |
||||
$r = run(new Impl()); |
||||
echo "result: $r\n"; |
||||
return $r === 'impl' ? 0 : 1; |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
result: impl |
||||
Loading…
Reference in new issue