- 添加匿名类索引计数器用于生成唯一类名 - 实现对象类型获取功能以支持动态类型解析 - 优化静态调用解析逻辑以处理变量表达式情况 - 添加测试用例验证匿名类静态访问功能pull/1/head
parent
35a81376a1
commit
a1d74df985
2 changed files with 43 additions and 3 deletions
@ -0,0 +1,25 @@ |
||||
--TEST-- |
||||
testing static access for methods and properties in anon classes |
||||
--FILE-- |
||||
<?php |
||||
function main() { |
||||
$anonClass = new class("cats", "dogs") { |
||||
public static $foo; |
||||
private static $bar; |
||||
|
||||
public function __construct($foo, $bar) { |
||||
static::$foo = $foo; |
||||
static::$bar = $bar; |
||||
} |
||||
|
||||
public static function getBar() { |
||||
return static::$bar; |
||||
} |
||||
}; |
||||
var_dump($anonClass::$foo); |
||||
var_dump($anonClass::getBar()); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
string(4) "cats" |
||||
string(4) "dogs" |
||||
Loading…
Reference in new issue