- 在trait中使用self时动态获取类名而不是固定为当前类 - 添加对trait定义的检测逻辑 - 确保trait中的常量访问正确解析 - 修复了method conflict测试用例 - 添加了traits测试文件验证功能正确性pull/1/head
parent
d8a828558d
commit
5b66ef2161
3 changed files with 42 additions and 2 deletions
@ -0,0 +1,34 @@ |
||||
--TEST-- |
||||
Method conflict in traits |
||||
--FILE-- |
||||
<?php |
||||
trait THello1 |
||||
{ |
||||
public function hello() |
||||
{ |
||||
var_dump(self::class); |
||||
var_dump($this->prop); |
||||
var_dump(self::HELLO); |
||||
var_dump(self::$staticProp); |
||||
} |
||||
} |
||||
|
||||
class TraitsTest |
||||
{ |
||||
use THello1; |
||||
protected string $prop = 'Hello 1'; |
||||
const HELLO = 'Hello 2'; |
||||
static int $staticProp = 2025; |
||||
} |
||||
|
||||
function main() |
||||
{ |
||||
$o = new TraitsTest; |
||||
$o->hello(); |
||||
} |
||||
?> |
||||
--EXPECT-- |
||||
string(10) "TraitsTest" |
||||
string(7) "Hello 1" |
||||
string(7) "Hello 2" |
||||
int(2025) |
||||
Loading…
Reference in new issue