| Conditions | 8 |
| Paths | 7 |
| Total Lines | 55 |
| Code Lines | 28 |
| 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 |
||
| 82 | $this->registerApps(OC_App::getEnabledApps()); |
||
| 83 | } |
||
| 84 | |||
| 85 | public function runLazyRegistration(string $appId): void { |
||
| 86 | $this->registerApps([$appId]); |
||
| 87 | } |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @param string[] $appIds |
||
| 91 | */ |
||
| 92 | private function registerApps(array $appIds): void { |
||
| 93 | if ($this->registrationContext === null) { |
||
| 94 | $this->registrationContext = new RegistrationContext($this->logger); |
||
| 95 | } |
||
| 96 | $apps = []; |
||
| 97 | foreach ($appIds as $appId) { |
||
| 98 | /* |
||
| 99 | * First, we have to enable the app's autoloader |
||
| 100 | * |
||
| 101 | * @todo use $this->appManager->getAppPath($appId) here |
||
| 102 | */ |
||
| 103 | $path = OC_App::getAppPath($appId); |
||
| 104 | if ($path === false) { |
||
| 105 | // Ignore |
||
| 106 | continue; |
||
| 107 | } |
||
| 108 | OC_App::registerAutoloading($appId, $path); |
||
| 109 | |||
| 110 | /* |
||
| 111 | * Next we check if there is an application class and it implements |
||
| 112 | * the \OCP\AppFramework\Bootstrap\IBootstrap interface |
||
| 113 | */ |
||
| 114 | $appNameSpace = App::buildAppNamespace($appId); |
||
| 115 | $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
||
| 116 | if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { |
||
| 117 | try { |
||
| 118 | /** @var IBootstrap|App $application */ |
||
| 119 | $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); |
||
| 120 | } catch (QueryException $e) { |
||
| 121 | // Weird, but ok |
||
| 122 | continue; |
||
| 123 | } |
||
| 124 | try { |
||
| 125 | $application->register($this->registrationContext->for($appId)); |
||
|
|
|||
| 126 | } catch (Throwable $e) { |
||
| 127 | $this->logger->logException($e, [ |
||
| 128 | 'message' => 'Error during app service registration: ' . $e->getMessage(), |
||
| 129 | 'level' => ILogger::FATAL, |
||
| 130 | ]); |
||
| 131 | } |
||
| 132 | } |
||
| 133 | } |
||
| 134 | |||
| 135 | /** |
||
| 136 | * Now that all register methods have been called, we can delegate the registrations |
||
| 137 | * to the actual services |
||
| 197 |
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.