The web installer needs to load extension PHP code for two purposes:
- the LoadExtensionSchemaUpdates hook which controls what extension schema updates need to be run
- non-extension.json extensions that use the legacy PHP entry point
This system is pretty fragile, as we just autoload the PHP classes (AutoloadClasses & AutoloadNamespaces) and then trigger the hook, hoping that it doesn't call out anywhere else. This usually violates developers' expectations that whatever PHP code they put in the hook will run (e.g. having services available, etc.).
More importantly, there's no real good reason for this. For 90% of extensions, the content in LoadExtensionSchemaUpdates is static, it could be moved into extension.json. And then we could get all the information we needed to do schema updates from the JSON file instead of needing to run any PHP code.