- 修改 CompilerBase.php 中的静态属性处理逻辑,正确区分 self 和 static 关键字 - 为 native-property-full-name.php 添加 writeStatic 测试方法 - 更新 NativePropertyTest.php 中的编译方法返回值类型和测试用例 - 添加静态属性晚绑定功能的完整测试用例 static-prop-late-static-binding.phptpull/2/head
parent
91675ed366
commit
cce6967acf
4 changed files with 65 additions and 2 deletions
@ -0,0 +1,39 @@ |
|||||||
|
--TEST-- |
||||||
|
Static native properties use late static binding for static::$prop |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
use native_types; |
||||||
|
|
||||||
|
class StaticPropBase { |
||||||
|
public static int $v = 1; |
||||||
|
|
||||||
|
public static function get(): int { |
||||||
|
return static::$v; |
||||||
|
} |
||||||
|
|
||||||
|
public static function set(int $v): void { |
||||||
|
static::$v = $v; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
class StaticPropChild extends StaticPropBase { |
||||||
|
public static int $v = 2; |
||||||
|
} |
||||||
|
|
||||||
|
function main(): void { |
||||||
|
var_dump(StaticPropBase::get()); |
||||||
|
var_dump(StaticPropChild::get()); |
||||||
|
|
||||||
|
StaticPropChild::set(9); |
||||||
|
|
||||||
|
var_dump(StaticPropBase::$v); |
||||||
|
var_dump(StaticPropChild::$v); |
||||||
|
var_dump(StaticPropChild::get()); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
int(1) |
||||||
|
int(2) |
||||||
|
int(1) |
||||||
|
int(9) |
||||||
|
int(9) |
||||||
Loading…
Reference in new issue