- 实现了类通过继承链查找接口常量的功能 - 添加了接口及其父接口常量的递归收集机制 - 在编译器中增加了对实现接口的类处理数组常量的支持 - 更新了常量访问检查逻辑以支持接口常量继承 - 添加了单元测试验证接口数组常量向实现类的传播 - 创建了AOT测试用例覆盖接口数组常量继承场景 - 重构了接口实现检查相关代码结构pull/5/head
parent
c4a8146661
commit
42ee6e3aa6
5 changed files with 180 additions and 24 deletions
@ -0,0 +1,14 @@ |
||||
<?php |
||||
interface InterfaceArrayConstantContract |
||||
{ |
||||
public const ITEMS = [1, 2, 3]; |
||||
} |
||||
|
||||
class InterfaceArrayConstantImpl implements InterfaceArrayConstantContract |
||||
{ |
||||
} |
||||
|
||||
function main() |
||||
{ |
||||
var_dump(InterfaceArrayConstantImpl::ITEMS); |
||||
} |
||||
@ -0,0 +1,60 @@ |
||||
--TEST-- |
||||
interface array constant inherited by implementing class |
||||
--FILE-- |
||||
<?php |
||||
interface InterfaceArrayConstSource |
||||
{ |
||||
public const DATA = [ |
||||
'php', |
||||
'aot', |
||||
]; |
||||
} |
||||
|
||||
class InterfaceArrayConstUser implements InterfaceArrayConstSource |
||||
{ |
||||
} |
||||
|
||||
interface InterfaceArrayConstChild extends InterfaceArrayConstSource |
||||
{ |
||||
} |
||||
|
||||
class InterfaceArrayConstChildUser implements InterfaceArrayConstChild |
||||
{ |
||||
} |
||||
|
||||
class InterfaceArrayConstParentUser implements InterfaceArrayConstSource |
||||
{ |
||||
} |
||||
|
||||
class InterfaceArrayConstGrandChildUser extends InterfaceArrayConstParentUser |
||||
{ |
||||
} |
||||
|
||||
function main() |
||||
{ |
||||
var_dump(InterfaceArrayConstUser::DATA); |
||||
var_dump(InterfaceArrayConstUser::DATA[1]); |
||||
var_dump(InterfaceArrayConstChildUser::DATA); |
||||
var_dump(InterfaceArrayConstGrandChildUser::DATA); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
array(2) { |
||||
[0]=> |
||||
string(3) "php" |
||||
[1]=> |
||||
string(3) "aot" |
||||
} |
||||
string(3) "aot" |
||||
array(2) { |
||||
[0]=> |
||||
string(3) "php" |
||||
[1]=> |
||||
string(3) "aot" |
||||
} |
||||
array(2) { |
||||
[0]=> |
||||
string(3) "php" |
||||
[1]=> |
||||
string(3) "aot" |
||||
} |
||||
Loading…
Reference in new issue