Say I got a class like:
<?
class ObjectModel {
}
and I got some other classes like:
<?
class SomeNewClass extends ObjectModel {
}
class SomeOtherNewClass extends ObjectModel {
}
Is there a way to get the children (SomeNewClass & SomeOtherNewClass) based on the ObjectModel class?
Yes, you can do it, DEMO
You can iterate all classes returned by
get_declared_classes()
and inspecting their Reflection (Reflection::isSubclassOf
)But - this won't work when you are using autoloading.
Not sure if this is going to get downvoted but you can hack your way through:
get_declared_classes
get_parent_class
for each class on 1It's not pretty, but if the child classes are loaded, it's possible.