@@ -97,20 +97,20 @@ discard block |
||
| 97 | 97 | /* Cannot be an alias because Output is not in OCA */ |
| 98 | 98 | $this->registerService(IOutput::class, fn (ContainerInterface $c): IOutput => new Output($c->get('webRoot'))); |
| 99 | 99 | |
| 100 | - $this->registerService(Folder::class, function () { |
|
| 100 | + $this->registerService(Folder::class, function() { |
|
| 101 | 101 | return $this->getServer()->getUserFolder(); |
| 102 | 102 | }); |
| 103 | 103 | |
| 104 | - $this->registerService(IAppData::class, function (ContainerInterface $c): IAppData { |
|
| 104 | + $this->registerService(IAppData::class, function(ContainerInterface $c): IAppData { |
|
| 105 | 105 | return $c->get(IAppDataFactory::class)->get($c->get('appName')); |
| 106 | 106 | }); |
| 107 | 107 | |
| 108 | - $this->registerService(IL10N::class, function (ContainerInterface $c) { |
|
| 108 | + $this->registerService(IL10N::class, function(ContainerInterface $c) { |
|
| 109 | 109 | return $this->getServer()->getL10N($c->get('appName')); |
| 110 | 110 | }); |
| 111 | 111 | |
| 112 | 112 | // Log wrappers |
| 113 | - $this->registerService(LoggerInterface::class, function (ContainerInterface $c) { |
|
| 113 | + $this->registerService(LoggerInterface::class, function(ContainerInterface $c) { |
|
| 114 | 114 | /* Cannot be an alias because it uses LoggerInterface so it would infinite loop */ |
| 115 | 115 | return new ScopedPsrLogger( |
| 116 | 116 | $c->get(PsrLoggerAdapter::class), |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | ); |
| 119 | 119 | }); |
| 120 | 120 | |
| 121 | - $this->registerService(IServerContainer::class, function () { |
|
| 121 | + $this->registerService(IServerContainer::class, function() { |
|
| 122 | 122 | return $this->getServer(); |
| 123 | 123 | }); |
| 124 | 124 | /** @deprecated 32.0.0 */ |
@@ -130,28 +130,28 @@ discard block |
||
| 130 | 130 | $this->registerDeprecatedAlias(IAppContainer::class, ContainerInterface::class); |
| 131 | 131 | |
| 132 | 132 | // commonly used attributes |
| 133 | - $this->registerService('userId', function (ContainerInterface $c): ?string { |
|
| 133 | + $this->registerService('userId', function(ContainerInterface $c): ?string { |
|
| 134 | 134 | return $c->get(ISession::class)->get('user_id'); |
| 135 | 135 | }); |
| 136 | 136 | |
| 137 | - $this->registerService('webRoot', function (ContainerInterface $c): string { |
|
| 137 | + $this->registerService('webRoot', function(ContainerInterface $c): string { |
|
| 138 | 138 | return $c->get(IServerContainer::class)->getWebRoot(); |
| 139 | 139 | }); |
| 140 | 140 | |
| 141 | - $this->registerService('OC_Defaults', function (ContainerInterface $c): object { |
|
| 141 | + $this->registerService('OC_Defaults', function(ContainerInterface $c): object { |
|
| 142 | 142 | return $c->get(IServerContainer::class)->get('ThemingDefaults'); |
| 143 | 143 | }); |
| 144 | 144 | |
| 145 | 145 | /** @deprecated 32.0.0 */ |
| 146 | 146 | $this->registerDeprecatedAlias('Protocol', Http::class); |
| 147 | - $this->registerService(Http::class, function (ContainerInterface $c) { |
|
| 147 | + $this->registerService(Http::class, function(ContainerInterface $c) { |
|
| 148 | 148 | $protocol = $c->get(IRequest::class)->getHttpProtocol(); |
| 149 | 149 | return new Http($_SERVER, $protocol); |
| 150 | 150 | }); |
| 151 | 151 | |
| 152 | 152 | /** @deprecated 32.0.0 */ |
| 153 | 153 | $this->registerDeprecatedAlias('Dispatcher', Dispatcher::class); |
| 154 | - $this->registerService(Dispatcher::class, function (ContainerInterface $c) { |
|
| 154 | + $this->registerService(Dispatcher::class, function(ContainerInterface $c) { |
|
| 155 | 155 | return new Dispatcher( |
| 156 | 156 | $c->get(Http::class), |
| 157 | 157 | $c->get(MiddlewareDispatcher::class), |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | */ |
| 178 | 178 | /** @deprecated 32.0.0 */ |
| 179 | 179 | $this->registerDeprecatedAlias('MiddlewareDispatcher', MiddlewareDispatcher::class); |
| 180 | - $this->registerService(MiddlewareDispatcher::class, function (ContainerInterface $c) { |
|
| 180 | + $this->registerService(MiddlewareDispatcher::class, function(ContainerInterface $c) { |
|
| 181 | 181 | $server = $this->getServer(); |
| 182 | 182 | |
| 183 | 183 | $dispatcher = new MiddlewareDispatcher(); |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | * @param string $serviceName e.g. 'OCA\Files\Capabilities' |
| 294 | 294 | */ |
| 295 | 295 | public function registerCapability($serviceName) { |
| 296 | - $this->query('OC\CapabilitiesManager')->registerCapability(function () use ($serviceName) { |
|
| 296 | + $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) { |
|
| 297 | 297 | return $this->query($serviceName); |
| 298 | 298 | }); |
| 299 | 299 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | return parent::query($name, chain: $chain); |
| 357 | 357 | } elseif ($this->appName === 'core' && str_starts_with($name, 'OC\\Core\\')) { |
| 358 | 358 | return parent::query($name, chain: $chain); |
| 359 | - } elseif (str_starts_with($name, \OC\AppFramework\App::buildAppNamespace($this->appName) . '\\')) { |
|
| 359 | + } elseif (str_starts_with($name, \OC\AppFramework\App::buildAppNamespace($this->appName).'\\')) { |
|
| 360 | 360 | return parent::query($name, chain: $chain); |
| 361 | 361 | } elseif ( |
| 362 | 362 | str_starts_with($name, 'OC\\AppFramework\\Services\\') |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | return parent::query($name, chain: $chain); |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - throw new QueryException('Could not resolve ' . $name . '!' |
|
| 369 | + throw new QueryException('Could not resolve '.$name.'!' |
|
| 370 | 370 | . ' Class can not be instantiated', 1); |
| 371 | 371 | } |
| 372 | 372 | } |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | if (PHP_VERSION_ID >= 80400 && self::$useLazyObjects && !$class->isInternal()) { |
| 67 | 67 | /* For PHP>=8.4, use a lazy ghost to delay constructor and dependency resolving */ |
| 68 | 68 | /** @psalm-suppress UndefinedMethod */ |
| 69 | - return $class->newLazyGhost(function (object $object) use ($constructor, $chain): void { |
|
| 69 | + return $class->newLazyGhost(function(object $object) use ($constructor, $chain): void { |
|
| 70 | 70 | /** @psalm-suppress DirectConstructorCall For lazy ghosts we have to call the constructor directly */ |
| 71 | 71 | $object->__construct(...$this->buildClassConstructorParameters($constructor, $chain)); |
| 72 | 72 | }); |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @param list<class-string> $chain |
| 80 | 80 | */ |
| 81 | 81 | private function buildClassConstructorParameters(\ReflectionMethod $constructor, array $chain): array { |
| 82 | - return array_map(function (ReflectionParameter $parameter) use ($chain) { |
|
| 82 | + return array_map(function(ReflectionParameter $parameter) use ($chain) { |
|
| 83 | 83 | $parameterType = $parameter->getType(); |
| 84 | 84 | |
| 85 | 85 | $resolveName = $parameter->getName(); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | // don't lose the error we got while trying to query by type |
| 113 | - throw new QueryException($e->getMessage(), (int)$e->getCode(), $e); |
|
| 113 | + throw new QueryException($e->getMessage(), (int) $e->getCode(), $e); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | * @param list<class-string> $chain |
| 125 | 125 | */ |
| 126 | 126 | public function resolve($name, array $chain = []) { |
| 127 | - $baseMsg = 'Could not resolve ' . $name . '!'; |
|
| 127 | + $baseMsg = 'Could not resolve '.$name.'!'; |
|
| 128 | 128 | try { |
| 129 | 129 | $class = new ReflectionClass($name); |
| 130 | 130 | if ($class->isInstantiable()) { |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | } catch (ReflectionException $e) { |
| 137 | 137 | // Class does not exist |
| 138 | - throw new QueryNotFoundException($baseMsg . ' ' . $e->getMessage()); |
|
| 138 | + throw new QueryNotFoundException($baseMsg.' '.$e->getMessage()); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | |
@@ -151,17 +151,17 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | if ($autoload) { |
| 153 | 153 | if (in_array($name, $chain, true)) { |
| 154 | - throw new RuntimeException('Tried to query ' . $name . ', but it is already in the chain: ' . implode(', ', $chain)); |
|
| 154 | + throw new RuntimeException('Tried to query '.$name.', but it is already in the chain: '.implode(', ', $chain)); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $object = $this->resolve($name, array_merge($chain, [$name])); |
| 158 | - $this->registerService($name, function () use ($object) { |
|
| 158 | + $this->registerService($name, function() use ($object) { |
|
| 159 | 159 | return $object; |
| 160 | 160 | }); |
| 161 | 161 | return $object; |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - throw new QueryNotFoundException('Could not resolve ' . $name . '!'); |
|
| 164 | + throw new QueryNotFoundException('Could not resolve '.$name.'!'); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param bool $shared |
| 183 | 183 | */ |
| 184 | 184 | public function registerService($name, Closure $closure, $shared = true) { |
| 185 | - $wrapped = function () use ($closure) { |
|
| 185 | + $wrapped = function() use ($closure) { |
|
| 186 | 186 | return $closure($this); |
| 187 | 187 | }; |
| 188 | 188 | $name = $this->sanitizeName($name); |
@@ -204,16 +204,16 @@ discard block |
||
| 204 | 204 | * @param string $target the target that should be resolved instead |
| 205 | 205 | */ |
| 206 | 206 | public function registerAlias($alias, $target): void { |
| 207 | - $this->registerService($alias, function (ContainerInterface $container) use ($target): mixed { |
|
| 207 | + $this->registerService($alias, function(ContainerInterface $container) use ($target): mixed { |
|
| 208 | 208 | return $container->get($target); |
| 209 | 209 | }, false); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | protected function registerDeprecatedAlias(string $alias, string $target): void { |
| 213 | - $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias): mixed { |
|
| 213 | + $this->registerService($alias, function(ContainerInterface $container) use ($target, $alias): mixed { |
|
| 214 | 214 | try { |
| 215 | 215 | $logger = $container->get(LoggerInterface::class); |
| 216 | - $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', [ |
|
| 216 | + $logger->debug('The requested alias "'.$alias.'" is deprecated. Please request "'.$target.'" directly. This alias will be removed in a future Nextcloud version.', [ |
|
| 217 | 217 | 'app' => $this->appName ?? 'serverDI', |
| 218 | 218 | ]); |
| 219 | 219 | } catch (ContainerExceptionInterface $e) { |