I have a class that implements an interface, and that interface extends another interface. The setting is like that:
interface A{
}
interface B extends A {
}
class C implements B {
}
$obj = new C();
I want to know which interfaces the object $obj implements. I tried to create a ReflectionClass object and then calling the getInterfaces method, but it only returns me the interface B:
$reflection = new ReflectionClass($obj);
print_r($reflection->getInterfaces());
I also tried to create a ReflectionClass object using the interface name, but when I call the getInterfaces() method, it returns an empty array.
Does any of you guys know how to get an interface name that extends a given interface?
Thanks a lot for your help,
Steve
You do not need Reflection for this. You can simply use
class_implements— Return the interfaces which are implemented by the given classExample for your code snippet:
Output: