I am sorry if this question was asked and answered elsewhere --- I do not know how to phrase my question in a proper way. Any hint will help.
I have "a bunch" of PHP-classes organised by PSR-4 principles (folders = class names, subfolder = sub-namespace-paths). There are sub-namespaces like accounting, printing, production, etc. Each of these subnamespaces might have an unknown amount of classes.
There is an interface in mynamespace\core\interfaces\types
. And there are classes that implement this interface in for example mynamespace\core\something.php
and mynamespace\core\subnamespace\somethingelse.php
and mynamespace\accounting\othertypes.php
, etc... and so on...
Is there a "proper" way to "know" all classes in this mynamespace
implementing mynamespace\core\interfaces\types
and running automatically a sub-method of these classes?
The specific user case here might be a group of "options" that are encapsulated in classes or "menu-items" in classes that can be "collected" and then initialise themselves somehow.
Update: Is there a way to use Reflection
-classes on a namespace to evaluate this information maybe?