| Conditions | 8 |
| Paths | 20 |
| Total Lines | 57 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 101 | private function registerApps(array $appIds): void { |
||
| 102 | if ($this->registrationContext === null) { |
||
| 103 | $this->registrationContext = new RegistrationContext($this->logger); |
||
| 104 | } |
||
| 105 | $apps = []; |
||
| 106 | foreach ($appIds as $appId) { |
||
| 107 | /* |
||
| 108 | * First, we have to enable the app's autoloader |
||
| 109 | * |
||
| 110 | * @todo use $this->appManager->getAppPath($appId) here |
||
| 111 | */ |
||
| 112 | $path = OC_App::getAppPath($appId); |
||
| 113 | if ($path === false) { |
||
| 114 | // Ignore |
||
| 115 | continue; |
||
| 116 | } |
||
| 117 | OC_App::registerAutoloading($appId, $path); |
||
| 118 | |||
| 119 | /* |
||
| 120 | * Next we check if there is an application class and it implements |
||
| 121 | * the \OCP\AppFramework\Bootstrap\IBootstrap interface |
||
| 122 | */ |
||
| 123 | $appNameSpace = App::buildAppNamespace($appId); |
||
| 124 | $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
||
| 125 | try { |
||
| 126 | if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { |
||
| 127 | try { |
||
| 128 | /** @var IBootstrap|App $application */ |
||
| 129 | $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); |
||
| 130 | } catch (QueryException $e) { |
||
| 131 | // Weird, but ok |
||
| 132 | continue; |
||
| 133 | } |
||
| 134 | |||
| 135 | $this->eventLogger->start('bootstrap:register_app_' . $appId, ''); |
||
| 136 | $application->register($this->registrationContext->for($appId)); |
||
|
|
|||
| 137 | $this->eventLogger->end('bootstrap:register_app_' . $appId); |
||
| 138 | } |
||
| 139 | } catch (Throwable $e) { |
||
| 140 | $this->logger->emergency('Error during app service registration: ' . $e->getMessage(), [ |
||
| 141 | 'exception' => $e, |
||
| 142 | 'app' => $appId, |
||
| 143 | ]); |
||
| 144 | continue; |
||
| 145 | } |
||
| 146 | } |
||
| 147 | |||
| 148 | /** |
||
| 149 | * Now that all register methods have been called, we can delegate the registrations |
||
| 150 | * to the actual services |
||
| 151 | */ |
||
| 152 | $this->registrationContext->delegateCapabilityRegistrations($apps); |
||
| 153 | $this->registrationContext->delegateCrashReporterRegistrations($apps, $this->registry); |
||
| 154 | $this->registrationContext->delegateDashboardPanelRegistrations($apps, $this->dashboardManager); |
||
| 155 | $this->registrationContext->delegateEventListenerRegistrations($this->eventDispatcher); |
||
| 156 | $this->registrationContext->delegateContainerRegistrations($apps); |
||
| 157 | $this->registrationContext->delegateMiddlewareRegistrations($apps); |
||
| 158 | } |
||
| 211 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.