本文整理汇总了PHP中ReflectionObject::getTraitNames方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionObject::getTraitNames方法的具体用法?PHP ReflectionObject::getTraitNames怎么用?PHP ReflectionObject::getTraitNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionObject
的用法示例。
在下文中一共展示了ReflectionObject::getTraitNames方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSerializable
/**
* Method that checks if the current instance implementing Serializable interface
*/
public function testSerializable()
{
if ($this instanceof \Serializable) {
echo get_class($this), ' implements `Serializable` interface now!', PHP_EOL;
$reflection = new \ReflectionObject($this);
var_dump($reflection->getInterfaceNames(), $reflection->getTraitNames());
} else {
echo get_class($this), ' does not implement `Serializable` interface', PHP_EOL;
}
}
示例2: testSerializable
/**
* Method that checks if the current instance implementing Serializable interface
*/
public function testSerializable()
{
if ($this instanceof \Serializable) {
echo get_class($this), ' implements `Serializable` interface now!', PHP_EOL;
$reflection = new \ReflectionObject($this);
echo "List of interfaces:", PHP_EOL;
foreach ($reflection->getInterfaceNames() as $interfaceName) {
echo '-> ', $interfaceName, PHP_EOL;
}
echo "List of traits:", PHP_EOL;
foreach ($reflection->getTraitNames() as $traitName) {
echo '-> ', $traitName, PHP_EOL;
}
} else {
echo get_class($this), ' does not implement `Serializable` interface', PHP_EOL;
}
}
示例3: _reflectionTraits
private function _reflectionTraits(\ReflectionObject $reflection)
{
$traits = $reflection->getTraitNames();
if (count($traits)) {
$name = '<span class="d-information" title="Traits this object uses"></span> ';
$name .= '<span class="d-obj-info">Traits</span>';
$traits = implode(', ', $traits);
$this->render($traits, $name);
}
}