ObjectFactory is intended to be an object construction helper, but object construction is the responsibility of the dependency injection container, so the preferred method should be by specifying a service (typically for the factory, although there might be instances where the service is the actual class to be returned). There should be a parameter for that.
Rough plan:
- make MediaWikiServices PSR-11 compatible (easy; just add get() and has() aliases, and make sure it and the exceptions it throws implement the right interfaces)
- make ObjectFactory::getObjectFromSpec take a PSR-11 service container as an optional argument
- add a service property to the spec array, to be used instead of class, and a factory_service property, to be used instead of factory. Not sure how the latter should look, as one would also need to specify what to call on the factory...