我在PHP中有一些别名特征:
class Foo {
use Bar, Other {
Bar as One;
Bar as Two;
Other as Three;
}
}
有没有办法获得该类当前使用的特征及其别名的列表?我知道PHP有class_uses(),但在上面的例子中只返回Bar和Other而不是One,Two或Three。我想要一个键=>原始名称和别名的值。有谁碰巧知道怎么样?我做了很多谷歌搜索没有结果。
答案 0 :(得分:2)
看起来您可以使用ReflectionClass
来获取此信息。特别是getTraitAliases
方法:
http://php.net/manual/en/reflectionclass.gettraitaliases.php