/
Introduce base-class based sub-class discovery [5.3.0-B1]
Introduce base-class based sub-class discovery [5.3.0-B1]
I've made quite a few improvements to the Phabricator tool recently and it uses quite different approach to autoloading:
- you never register a class specifically or place it under namespace
- the tokenizer discovers all PHP files in project and records this:
- what classes/interfaces/traits are created in each file
- what class/interface/trait extends other class/interface/trait
- extensively using sub-classing
- has method to return all class instances that sub-class given class (directly or indirectly)
I believe latter can be a huge win for In-Portal before:
- you only register class once in unit config and class itself then knows how to integrate with system
- no need to create several configuration options for thing, e.g. (all things below aren't yet committed):
- we register router class (with on configuration option) and specify it's priority (with another configuration option) - Routing Ideas
- we register CLI command class (with on configuration option) and specify that it should be used (with another configuration option) - [console] Use Symfony Console Component for Automation [5.3.0-B1]
- we register scheduled task class (with on configuration option) and specify it's run schedule (with another configuration option) - Alexander Obuhovich's Home
To make this happen we need to, at class registration time (when unit config cache is rebuilt), also create records that will:
- record all implemented interfaces (for classes only)
- record all parent class/interfaces (for classes and interfaces)
- create method "
Factory::getSubClasses($class_name)
"