Fix type-hints for boot services
authorTim Otten <totten@civicrm.org>
Fri, 25 Aug 2023 23:33:49 +0000 (16:33 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 25 Aug 2023 23:35:58 +0000 (16:35 -0700)
Civi/Core/Container.php

index c229d8d814c89c60666c687ea4c5c2bf843fa9a8..bbe0527653001260fda51f2678b9c351d08762b9 100644 (file)
@@ -248,11 +248,23 @@ class Container {
     $container->setDefinition('crypto.jwt', new Definition('Civi\Crypto\CryptoJwt', []))
       ->setPublic(TRUE);
 
+    $bootServiceTypes = [
+      'cache.settings' => \CRM_Utils_Cache_Interface::class,
+      'dispatcher.boot' => CiviEventDispatcher::class,
+      'lockManager' => LockManager::class,
+      'paths' => Paths::class,
+      'runtime' => \CRM_Core_Config_Runtime::class,
+      'settings_manager' => SettingsManager::class,
+      'userPermissionClass' => \CRM_Core_Permission_Base::class,
+      'userSystem' => \CRM_Utils_System_Base::class,
+    ];
     if (empty(\Civi::$statics[__CLASS__]['boot'])) {
       throw new \RuntimeException('Cannot initialize container. Boot services are undefined.');
     }
     foreach (\Civi::$statics[__CLASS__]['boot'] as $bootService => $def) {
-      $container->setDefinition($bootService, new Definition())->setSynthetic(TRUE)->setPublic(TRUE);
+      $container->setDefinition($bootService, new Definition($bootServiceTypes[$bootService] ?? NULL))
+        ->setSynthetic(TRUE)
+        ->setPublic(TRUE);
     }
 
     // Expose legacy singletons as services in the container.