<?php
class A {}
class B extends A {}
interface I {}
trait T {}
class C extends B implements I {
use T;
}
Operation | is_a() | is_subclass_of() | instanceof |
---|---|---|---|
A of A | ✅ | ❌ | ✅ |
A of B | ❌ | ❌ | ❌ |
A of I | ❌ | ❌ | ❌ |
A of T | ❌ | ❌ | ❌ |
A of C | ❌ | ❌ | ❌ |
B of A | ✅ | ✅ | ✅ |
B of B | ✅ | ❌ | ✅ |
B of I | ❌ | ❌ | ❌ |
B of T | ❌ | ❌ | ❌ |
B of C | ❌ | ❌ | ❌ |
I of A | ❌ | ❌ | ❌ |
I of B | ❌ | ❌ | ❌ |
I of I | ✅ | ❌ | ❌ |
I of T | ❌ | ❌ | ❌ |
I of C | ❌ | ❌ | ❌ |
T of A | ❌ | ❌ | ❌ |
T of B | ❌ | ❌ | ❌ |
T of I | ❌ | ❌ | ❌ |
T of T | ✅ | ❌ | ❌ |
T of C | ❌ | ❌ | ❌ |
C of A | ✅ | ✅ | ✅ |
C of B | ✅ | ✅ | ✅ |
C of I | ✅ | ✅ | ✅ |
C of T | ❌ | ❌ | ❌ |
C of C | ✅ | ❌ | ✅ |
Let's add the check but also leave the initials.