php find all subclasses of class

Solutions on MaxInterview for php find all subclasses of class by the best coders in the world

showing results for - "php find all subclasses of class"
Johnny
04 Oct 2016
1/* Loops through all loaded classes (get_declared_classes()) and
2returns an array of subclasses of the provided $parent */
3function getSubclasses(string $parent):array {
4	return array_reduce(get_declared_classes(), function($subclasses, $class) use ($parent) {
5		if (is_subclass_of($class, $parent)) {
6			$subclasses[] = $class;
7		}
8		return $subclasses;
9	}, []);
10}