/** * 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; } }
/** * 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; } }
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); } }