@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | $userIdentifier, |
61 | 61 | $period, |
62 | 62 | $limit) { |
63 | - $existingAttempts = $this->backend->getAttempts($methodIdentifier, $userIdentifier, (int)$period); |
|
64 | - if ($existingAttempts >= (int)$limit) { |
|
63 | + $existingAttempts = $this->backend->getAttempts($methodIdentifier, $userIdentifier, (int) $period); |
|
64 | + if ($existingAttempts >= (int) $limit) { |
|
65 | 65 | throw new RateLimitExceededException(); |
66 | 66 | } |
67 | 67 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $ip) { |
84 | 84 | $ipSubnet = (new IpAddress($ip))->getSubnet(); |
85 | 85 | |
86 | - $anonHashIdentifier = hash('sha512', 'anon::' . $identifier . $ipSubnet); |
|
86 | + $anonHashIdentifier = hash('sha512', 'anon::'.$identifier.$ipSubnet); |
|
87 | 87 | $this->register($identifier, $anonHashIdentifier, $anonPeriod, $anonLimit); |
88 | 88 | } |
89 | 89 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $userLimit, |
101 | 101 | $userPeriod, |
102 | 102 | IUser $user) { |
103 | - $userHashIdentifier = hash('sha512', 'user::' . $identifier . $user->getUID()); |
|
103 | + $userHashIdentifier = hash('sha512', 'user::'.$identifier.$user->getUID()); |
|
104 | 104 | $this->register($identifier, $userHashIdentifier, $userPeriod, $userLimit); |
105 | 105 | } |
106 | 106 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | private function getCutoff($expire) { |
80 | 80 | $d1 = new \DateTime(); |
81 | 81 | $d2 = clone $d1; |
82 | - $d2->sub(new \DateInterval('PT' . $expire . 'S')); |
|
82 | + $d2->sub(new \DateInterval('PT'.$expire.'S')); |
|
83 | 83 | return $d2->diff($d1); |
84 | 84 | } |
85 | 85 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | $ip, |
95 | 95 | array $metadata = []) { |
96 | 96 | // No need to log if the bruteforce protection is disabled |
97 | - if($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) { |
|
97 | + if ($this->config->getSystemValue('auth.bruteforce.protection.enabled', true) === false) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | 100 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $values = [ |
103 | 103 | 'action' => $action, |
104 | 104 | 'occurred' => $this->timeFactory->getTime(), |
105 | - 'ip' => (string)$ipAddress, |
|
105 | + 'ip' => (string) $ipAddress, |
|
106 | 106 | 'subnet' => $ipAddress->getSubnet(), |
107 | 107 | 'metadata' => json_encode($metadata), |
108 | 108 | ]; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | |
121 | 121 | $qb = $this->db->getQueryBuilder(); |
122 | 122 | $qb->insert('bruteforce_attempts'); |
123 | - foreach($values as $column => $value) { |
|
123 | + foreach ($values as $column => $value) { |
|
124 | 124 | $qb->setValue($column, $qb->createNamedParameter($value)); |
125 | 125 | } |
126 | 126 | $qb->execute(); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | $cx = explode('/', $cidr); |
156 | 156 | $addr = $cx[0]; |
157 | - $mask = (int)$cx[1]; |
|
157 | + $mask = (int) $cx[1]; |
|
158 | 158 | |
159 | 159 | // Do not compare ipv4 to ipv6 |
160 | 160 | if (($type === 4 && !filter_var($addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) || |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | $addr = inet_pton($addr); |
166 | 166 | |
167 | 167 | $valid = true; |
168 | - for($i = 0; $i < $mask; $i++) { |
|
169 | - $part = ord($addr[(int)($i/8)]); |
|
170 | - $orig = ord($ip[(int)($i/8)]); |
|
168 | + for ($i = 0; $i < $mask; $i++) { |
|
169 | + $part = ord($addr[(int) ($i / 8)]); |
|
170 | + $orig = ord($ip[(int) ($i / 8)]); |
|
171 | 171 | |
172 | 172 | $part = $part & (15 << (1 - ($i % 2))); |
173 | 173 | $orig = $orig & (15 << (1 - ($i % 2))); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | */ |
197 | 197 | public function getDelay($ip, $action = '') { |
198 | 198 | $ipAddress = new IpAddress($ip); |
199 | - if ($this->isIPWhitelisted((string)$ipAddress)) { |
|
199 | + if ($this->isIPWhitelisted((string) $ipAddress)) { |
|
200 | 200 | return 0; |
201 | 201 | } |
202 | 202 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | |
223 | 223 | $maxDelay = 30; |
224 | 224 | $firstDelay = 0.1; |
225 | - if ($attempts > (8 * PHP_INT_SIZE - 1)) { |
|
225 | + if ($attempts > (8 * PHP_INT_SIZE - 1)) { |
|
226 | 226 | // Don't ever overflow. Just assume the maxDelay time:s |
227 | 227 | $firstDelay = $maxDelay; |
228 | 228 | } else { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
132 | 132 | $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
133 | 133 | |
134 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
134 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
135 | 135 | return new PreviewManager( |
136 | 136 | $c->getConfig(), |
137 | 137 | $c->getRootFolder(), |
@@ -142,13 +142,13 @@ discard block |
||
142 | 142 | }); |
143 | 143 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
144 | 144 | |
145 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
145 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
146 | 146 | return new \OC\Preview\Watcher( |
147 | 147 | $c->getAppDataDir('preview') |
148 | 148 | ); |
149 | 149 | }); |
150 | 150 | |
151 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
151 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
152 | 152 | $view = new View(); |
153 | 153 | $util = new Encryption\Util( |
154 | 154 | $view, |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | ); |
167 | 167 | }); |
168 | 168 | |
169 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
169 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
170 | 170 | $util = new Encryption\Util( |
171 | 171 | new View(), |
172 | 172 | $c->getUserManager(), |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | return new Encryption\File($util); |
177 | 177 | }); |
178 | 178 | |
179 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
179 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
180 | 180 | $view = new View(); |
181 | 181 | $util = new Encryption\Util( |
182 | 182 | $view, |
@@ -187,32 +187,32 @@ discard block |
||
187 | 187 | |
188 | 188 | return new Encryption\Keys\Storage($view, $util); |
189 | 189 | }); |
190 | - $this->registerService('TagMapper', function (Server $c) { |
|
190 | + $this->registerService('TagMapper', function(Server $c) { |
|
191 | 191 | return new TagMapper($c->getDatabaseConnection()); |
192 | 192 | }); |
193 | 193 | |
194 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
194 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
195 | 195 | $tagMapper = $c->query('TagMapper'); |
196 | 196 | return new TagManager($tagMapper, $c->getUserSession()); |
197 | 197 | }); |
198 | 198 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
199 | 199 | |
200 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
200 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
201 | 201 | $config = $c->getConfig(); |
202 | 202 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
203 | 203 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
204 | 204 | $factory = new $factoryClass($this); |
205 | 205 | return $factory; |
206 | 206 | }); |
207 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
207 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
208 | 208 | return $c->query('SystemTagManagerFactory')->getManager(); |
209 | 209 | }); |
210 | 210 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
211 | 211 | |
212 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
212 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
213 | 213 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
214 | 214 | }); |
215 | - $this->registerService('RootFolder', function (Server $c) { |
|
215 | + $this->registerService('RootFolder', function(Server $c) { |
|
216 | 216 | $manager = \OC\Files\Filesystem::getMountManager(null); |
217 | 217 | $view = new View(); |
218 | 218 | $root = new Root( |
@@ -240,30 +240,30 @@ discard block |
||
240 | 240 | }); |
241 | 241 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
242 | 242 | |
243 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
243 | + $this->registerService(\OCP\IUserManager::class, function(Server $c) { |
|
244 | 244 | $config = $c->getConfig(); |
245 | 245 | return new \OC\User\Manager($config); |
246 | 246 | }); |
247 | 247 | $this->registerAlias('UserManager', \OCP\IUserManager::class); |
248 | 248 | |
249 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
249 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
250 | 250 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
251 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
251 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
252 | 252 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
253 | 253 | }); |
254 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
254 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
255 | 255 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
256 | 256 | }); |
257 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
257 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
258 | 258 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
259 | 259 | }); |
260 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
260 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
261 | 261 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
262 | 262 | }); |
263 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
263 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
264 | 264 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
265 | 265 | }); |
266 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
266 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
267 | 267 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
268 | 268 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
269 | 269 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -283,11 +283,11 @@ discard block |
||
283 | 283 | return new Store($session, $logger, $tokenProvider); |
284 | 284 | }); |
285 | 285 | $this->registerAlias(IStore::class, Store::class); |
286 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
286 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) { |
|
287 | 287 | $dbConnection = $c->getDatabaseConnection(); |
288 | 288 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
289 | 289 | }); |
290 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
290 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) { |
|
291 | 291 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
292 | 292 | $crypto = $c->getCrypto(); |
293 | 293 | $config = $c->getConfig(); |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | }); |
298 | 298 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
299 | 299 | |
300 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
300 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
301 | 301 | $manager = $c->getUserManager(); |
302 | 302 | $session = new \OC\Session\Memory(''); |
303 | 303 | $timeFactory = new TimeFactory(); |
@@ -310,40 +310,40 @@ discard block |
||
310 | 310 | } |
311 | 311 | |
312 | 312 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
313 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
313 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
314 | 314 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
315 | 315 | }); |
316 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
316 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
317 | 317 | /** @var $user \OC\User\User */ |
318 | 318 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
319 | 319 | }); |
320 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
320 | + $userSession->listen('\OC\User', 'preDelete', function($user) { |
|
321 | 321 | /** @var $user \OC\User\User */ |
322 | 322 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
323 | 323 | }); |
324 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
324 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
325 | 325 | /** @var $user \OC\User\User */ |
326 | 326 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
327 | 327 | }); |
328 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
328 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
329 | 329 | /** @var $user \OC\User\User */ |
330 | 330 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
331 | 331 | }); |
332 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
332 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
333 | 333 | /** @var $user \OC\User\User */ |
334 | 334 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
335 | 335 | }); |
336 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
336 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
337 | 337 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
338 | 338 | }); |
339 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
339 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
340 | 340 | /** @var $user \OC\User\User */ |
341 | 341 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
342 | 342 | }); |
343 | - $userSession->listen('\OC\User', 'logout', function () { |
|
343 | + $userSession->listen('\OC\User', 'logout', function() { |
|
344 | 344 | \OC_Hook::emit('OC_User', 'logout', array()); |
345 | 345 | }); |
346 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
|
346 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value) { |
|
347 | 347 | /** @var $user \OC\User\User */ |
348 | 348 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
349 | 349 | }); |
@@ -351,14 +351,14 @@ discard block |
||
351 | 351 | }); |
352 | 352 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
353 | 353 | |
354 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
354 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
355 | 355 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
356 | 356 | }); |
357 | 357 | |
358 | 358 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
359 | 359 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
360 | 360 | |
361 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
361 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
362 | 362 | return new \OC\AllConfig( |
363 | 363 | $c->getSystemConfig() |
364 | 364 | ); |
@@ -366,17 +366,17 @@ discard block |
||
366 | 366 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
367 | 367 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
368 | 368 | |
369 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
369 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
370 | 370 | return new \OC\SystemConfig($config); |
371 | 371 | }); |
372 | 372 | |
373 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
373 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
374 | 374 | return new \OC\AppConfig($c->getDatabaseConnection()); |
375 | 375 | }); |
376 | 376 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
377 | 377 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
378 | 378 | |
379 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
379 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
380 | 380 | return new \OC\L10N\Factory( |
381 | 381 | $c->getConfig(), |
382 | 382 | $c->getRequest(), |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | }); |
387 | 387 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
388 | 388 | |
389 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
389 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
390 | 390 | $config = $c->getConfig(); |
391 | 391 | $cacheFactory = $c->getMemCacheFactory(); |
392 | 392 | return new \OC\URLGenerator( |
@@ -396,10 +396,10 @@ discard block |
||
396 | 396 | }); |
397 | 397 | $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
398 | 398 | |
399 | - $this->registerService('AppHelper', function ($c) { |
|
399 | + $this->registerService('AppHelper', function($c) { |
|
400 | 400 | return new \OC\AppHelper(); |
401 | 401 | }); |
402 | - $this->registerService('AppFetcher', function ($c) { |
|
402 | + $this->registerService('AppFetcher', function($c) { |
|
403 | 403 | return new AppFetcher( |
404 | 404 | $this->getAppDataDir('appstore'), |
405 | 405 | $this->getHTTPClientService(), |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | $this->getConfig() |
408 | 408 | ); |
409 | 409 | }); |
410 | - $this->registerService('CategoryFetcher', function ($c) { |
|
410 | + $this->registerService('CategoryFetcher', function($c) { |
|
411 | 411 | return new CategoryFetcher( |
412 | 412 | $this->getAppDataDir('appstore'), |
413 | 413 | $this->getHTTPClientService(), |
@@ -416,21 +416,21 @@ discard block |
||
416 | 416 | ); |
417 | 417 | }); |
418 | 418 | |
419 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
419 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
420 | 420 | return new Cache\File(); |
421 | 421 | }); |
422 | 422 | $this->registerAlias('UserCache', \OCP\ICache::class); |
423 | 423 | |
424 | - $this->registerService(Factory::class, function (Server $c) { |
|
424 | + $this->registerService(Factory::class, function(Server $c) { |
|
425 | 425 | $config = $c->getConfig(); |
426 | 426 | |
427 | 427 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
428 | 428 | $v = \OC_App::getAppVersions(); |
429 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
429 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php')); |
|
430 | 430 | $version = implode(',', $v); |
431 | 431 | $instanceId = \OC_Util::getInstanceId(); |
432 | 432 | $path = \OC::$SERVERROOT; |
433 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
433 | + $prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT); |
|
434 | 434 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
435 | 435 | $config->getSystemValue('memcache.local', null), |
436 | 436 | $config->getSystemValue('memcache.distributed', null), |
@@ -447,12 +447,12 @@ discard block |
||
447 | 447 | $this->registerAlias('MemCacheFactory', Factory::class); |
448 | 448 | $this->registerAlias(ICacheFactory::class, Factory::class); |
449 | 449 | |
450 | - $this->registerService('RedisFactory', function (Server $c) { |
|
450 | + $this->registerService('RedisFactory', function(Server $c) { |
|
451 | 451 | $systemConfig = $c->getSystemConfig(); |
452 | 452 | return new RedisFactory($systemConfig); |
453 | 453 | }); |
454 | 454 | |
455 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
455 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
456 | 456 | return new \OC\Activity\Manager( |
457 | 457 | $c->getRequest(), |
458 | 458 | $c->getUserSession(), |
@@ -462,14 +462,14 @@ discard block |
||
462 | 462 | }); |
463 | 463 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
464 | 464 | |
465 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
465 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
466 | 466 | return new \OC\Activity\EventMerger( |
467 | 467 | $c->getL10N('lib') |
468 | 468 | ); |
469 | 469 | }); |
470 | 470 | $this->registerAlias(IValidator::class, Validator::class); |
471 | 471 | |
472 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
472 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
473 | 473 | return new AvatarManager( |
474 | 474 | $c->getUserManager(), |
475 | 475 | $c->getAppDataDir('avatar'), |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | }); |
481 | 481 | $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
482 | 482 | |
483 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
483 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
484 | 484 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
485 | 485 | $logger = Log::getLogClass($logType); |
486 | 486 | call_user_func(array($logger, 'init')); |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | }); |
490 | 490 | $this->registerAlias('Logger', \OCP\ILogger::class); |
491 | 491 | |
492 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
492 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
493 | 493 | $config = $c->getConfig(); |
494 | 494 | return new \OC\BackgroundJob\JobList( |
495 | 495 | $c->getDatabaseConnection(), |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | }); |
500 | 500 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
501 | 501 | |
502 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
502 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
503 | 503 | $cacheFactory = $c->getMemCacheFactory(); |
504 | 504 | $logger = $c->getLogger(); |
505 | 505 | if ($cacheFactory->isAvailable()) { |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | }); |
512 | 512 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
513 | 513 | |
514 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
514 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
515 | 515 | return new Search(); |
516 | 516 | }); |
517 | 517 | $this->registerAlias('Search', \OCP\ISearch::class); |
@@ -531,27 +531,27 @@ discard block |
||
531 | 531 | ); |
532 | 532 | }); |
533 | 533 | |
534 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
534 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
535 | 535 | return new SecureRandom(); |
536 | 536 | }); |
537 | 537 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
538 | 538 | |
539 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
539 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
540 | 540 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
541 | 541 | }); |
542 | 542 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
543 | 543 | |
544 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
544 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
545 | 545 | return new Hasher($c->getConfig()); |
546 | 546 | }); |
547 | 547 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
548 | 548 | |
549 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
549 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
550 | 550 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
551 | 551 | }); |
552 | 552 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
553 | 553 | |
554 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
554 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
555 | 555 | $systemConfig = $c->getSystemConfig(); |
556 | 556 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
557 | 557 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | }); |
566 | 566 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
567 | 567 | |
568 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
568 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
569 | 569 | $config = $c->getConfig(); |
570 | 570 | return new HTTPHelper( |
571 | 571 | $config, |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | ); |
574 | 574 | }); |
575 | 575 | |
576 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
576 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
577 | 577 | $user = \OC_User::getUser(); |
578 | 578 | $uid = $user ? $user : null; |
579 | 579 | return new ClientService( |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | }); |
584 | 584 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
585 | 585 | |
586 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
586 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
587 | 587 | if ($c->getSystemConfig()->getValue('debug', false)) { |
588 | 588 | return new EventLogger(); |
589 | 589 | } else { |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | }); |
593 | 593 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
594 | 594 | |
595 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
595 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
596 | 596 | if ($c->getSystemConfig()->getValue('debug', false)) { |
597 | 597 | return new QueryLogger(); |
598 | 598 | } else { |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | }); |
602 | 602 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
603 | 603 | |
604 | - $this->registerService(TempManager::class, function (Server $c) { |
|
604 | + $this->registerService(TempManager::class, function(Server $c) { |
|
605 | 605 | return new TempManager( |
606 | 606 | $c->getLogger(), |
607 | 607 | $c->getConfig() |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | $this->registerAlias('TempManager', TempManager::class); |
611 | 611 | $this->registerAlias(ITempManager::class, TempManager::class); |
612 | 612 | |
613 | - $this->registerService(AppManager::class, function (Server $c) { |
|
613 | + $this->registerService(AppManager::class, function(Server $c) { |
|
614 | 614 | return new \OC\App\AppManager( |
615 | 615 | $c->getUserSession(), |
616 | 616 | $c->getAppConfig(), |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | $this->registerAlias('AppManager', AppManager::class); |
623 | 623 | $this->registerAlias(IAppManager::class, AppManager::class); |
624 | 624 | |
625 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
625 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
626 | 626 | return new DateTimeZone( |
627 | 627 | $c->getConfig(), |
628 | 628 | $c->getSession() |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | }); |
631 | 631 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
632 | 632 | |
633 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
633 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
634 | 634 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
635 | 635 | |
636 | 636 | return new DateTimeFormatter( |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | }); |
641 | 641 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
642 | 642 | |
643 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
643 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
644 | 644 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
645 | 645 | $listener = new UserMountCacheListener($mountCache); |
646 | 646 | $listener->listen($c->getUserManager()); |
@@ -648,10 +648,10 @@ discard block |
||
648 | 648 | }); |
649 | 649 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
650 | 650 | |
651 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
651 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
652 | 652 | $loader = \OC\Files\Filesystem::getLoader(); |
653 | 653 | $mountCache = $c->query('UserMountCache'); |
654 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
654 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
655 | 655 | |
656 | 656 | // builtin providers |
657 | 657 | |
@@ -664,14 +664,14 @@ discard block |
||
664 | 664 | }); |
665 | 665 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
666 | 666 | |
667 | - $this->registerService('IniWrapper', function ($c) { |
|
667 | + $this->registerService('IniWrapper', function($c) { |
|
668 | 668 | return new IniGetWrapper(); |
669 | 669 | }); |
670 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
670 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
671 | 671 | $jobList = $c->getJobList(); |
672 | 672 | return new AsyncBus($jobList); |
673 | 673 | }); |
674 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
674 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
675 | 675 | return new TrustedDomainHelper($this->getConfig()); |
676 | 676 | }); |
677 | 677 | $this->registerService('Throttler', function(Server $c) { |
@@ -682,10 +682,10 @@ discard block |
||
682 | 682 | $c->getConfig() |
683 | 683 | ); |
684 | 684 | }); |
685 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
685 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
686 | 686 | // IConfig and IAppManager requires a working database. This code |
687 | 687 | // might however be called when ownCloud is not yet setup. |
688 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
688 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
689 | 689 | $config = $c->getConfig(); |
690 | 690 | $appManager = $c->getAppManager(); |
691 | 691 | } else { |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | $c->getTempManager() |
704 | 704 | ); |
705 | 705 | }); |
706 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
706 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
707 | 707 | if (isset($this['urlParams'])) { |
708 | 708 | $urlParams = $this['urlParams']; |
709 | 709 | } else { |
@@ -739,7 +739,7 @@ discard block |
||
739 | 739 | }); |
740 | 740 | $this->registerAlias('Request', \OCP\IRequest::class); |
741 | 741 | |
742 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
742 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
743 | 743 | return new Mailer( |
744 | 744 | $c->getConfig(), |
745 | 745 | $c->getLogger(), |
@@ -753,14 +753,14 @@ discard block |
||
753 | 753 | $this->registerService('LDAPProvider', function(Server $c) { |
754 | 754 | $config = $c->getConfig(); |
755 | 755 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
756 | - if(is_null($factoryClass)) { |
|
756 | + if (is_null($factoryClass)) { |
|
757 | 757 | throw new \Exception('ldapProviderFactory not set'); |
758 | 758 | } |
759 | 759 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
760 | 760 | $factory = new $factoryClass($this); |
761 | 761 | return $factory->getLDAPProvider(); |
762 | 762 | }); |
763 | - $this->registerService('LockingProvider', function (Server $c) { |
|
763 | + $this->registerService('LockingProvider', function(Server $c) { |
|
764 | 764 | $ini = $c->getIniWrapper(); |
765 | 765 | $config = $c->getConfig(); |
766 | 766 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -776,37 +776,37 @@ discard block |
||
776 | 776 | return new NoopLockingProvider(); |
777 | 777 | }); |
778 | 778 | |
779 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
779 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
780 | 780 | return new \OC\Files\Mount\Manager(); |
781 | 781 | }); |
782 | 782 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
783 | 783 | |
784 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
784 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
785 | 785 | return new \OC\Files\Type\Detection( |
786 | 786 | $c->getURLGenerator(), |
787 | 787 | \OC::$configDir, |
788 | - \OC::$SERVERROOT . '/resources/config/' |
|
788 | + \OC::$SERVERROOT.'/resources/config/' |
|
789 | 789 | ); |
790 | 790 | }); |
791 | 791 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
792 | 792 | |
793 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
793 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
794 | 794 | return new \OC\Files\Type\Loader( |
795 | 795 | $c->getDatabaseConnection() |
796 | 796 | ); |
797 | 797 | }); |
798 | 798 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
799 | 799 | |
800 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
800 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
801 | 801 | return new Manager( |
802 | 802 | $c->query(IValidator::class) |
803 | 803 | ); |
804 | 804 | }); |
805 | 805 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
806 | 806 | |
807 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
807 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
808 | 808 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
809 | - $manager->registerCapability(function () use ($c) { |
|
809 | + $manager->registerCapability(function() use ($c) { |
|
810 | 810 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
811 | 811 | }); |
812 | 812 | return $manager; |
@@ -848,13 +848,13 @@ discard block |
||
848 | 848 | } |
849 | 849 | return new \OC_Defaults(); |
850 | 850 | }); |
851 | - $this->registerService(EventDispatcher::class, function () { |
|
851 | + $this->registerService(EventDispatcher::class, function() { |
|
852 | 852 | return new EventDispatcher(); |
853 | 853 | }); |
854 | 854 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
855 | 855 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
856 | 856 | |
857 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
857 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
858 | 858 | // FIXME: Instantiiated here due to cyclic dependency |
859 | 859 | $request = new Request( |
860 | 860 | [ |
@@ -879,7 +879,7 @@ discard block |
||
879 | 879 | $request |
880 | 880 | ); |
881 | 881 | }); |
882 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
882 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
883 | 883 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
884 | 884 | |
885 | 885 | return new CsrfTokenManager( |
@@ -887,10 +887,10 @@ discard block |
||
887 | 887 | $c->query(SessionStorage::class) |
888 | 888 | ); |
889 | 889 | }); |
890 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
890 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
891 | 891 | return new SessionStorage($c->getSession()); |
892 | 892 | }); |
893 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
893 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
894 | 894 | return new ContentSecurityPolicyManager(); |
895 | 895 | }); |
896 | 896 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
@@ -941,29 +941,29 @@ discard block |
||
941 | 941 | ); |
942 | 942 | return $manager; |
943 | 943 | }); |
944 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
944 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
945 | 945 | return new \OC\Files\AppData\Factory( |
946 | 946 | $c->getRootFolder(), |
947 | 947 | $c->getSystemConfig() |
948 | 948 | ); |
949 | 949 | }); |
950 | 950 | |
951 | - $this->registerService('LockdownManager', function (Server $c) { |
|
951 | + $this->registerService('LockdownManager', function(Server $c) { |
|
952 | 952 | return new LockdownManager(function() use ($c) { |
953 | 953 | return $c->getSession(); |
954 | 954 | }); |
955 | 955 | }); |
956 | 956 | |
957 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
957 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
958 | 958 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
959 | 959 | }); |
960 | 960 | |
961 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
961 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
962 | 962 | return new CloudIdManager(); |
963 | 963 | }); |
964 | 964 | |
965 | 965 | /* To trick DI since we don't extend the DIContainer here */ |
966 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
966 | + $this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) { |
|
967 | 967 | return new CleanPreviewsBackgroundJob( |
968 | 968 | $c->getRootFolder(), |
969 | 969 | $c->getLogger(), |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
979 | 979 | $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
980 | 980 | |
981 | - $this->registerService(Defaults::class, function (Server $c) { |
|
981 | + $this->registerService(Defaults::class, function(Server $c) { |
|
982 | 982 | return new Defaults( |
983 | 983 | $c->getThemingDefaults() |
984 | 984 | ); |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | * @deprecated since 9.2.0 use IAppData |
1125 | 1125 | */ |
1126 | 1126 | public function getAppFolder() { |
1127 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1127 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1128 | 1128 | $root = $this->getRootFolder(); |
1129 | 1129 | if (!$root->nodeExists($dir)) { |
1130 | 1130 | $folder = $root->newFolder($dir); |
@@ -40,19 +40,19 @@ discard block |
||
40 | 40 | * @param object $object an object or classname |
41 | 41 | * @param string $method the method which we want to inspect |
42 | 42 | */ |
43 | - public function reflect($object, $method){ |
|
43 | + public function reflect($object, $method) { |
|
44 | 44 | $reflection = new \ReflectionMethod($object, $method); |
45 | 45 | $docs = $reflection->getDocComment(); |
46 | 46 | |
47 | 47 | // extract everything prefixed by @ and first letter uppercase |
48 | 48 | preg_match_all('/^\h+\*\h+@(?P<annotation>[A-Z]\w+)((?P<parameter>.*))?$/m', $docs, $matches); |
49 | - foreach($matches['annotation'] as $key => $annontation) { |
|
49 | + foreach ($matches['annotation'] as $key => $annontation) { |
|
50 | 50 | $annotationValue = $matches['parameter'][$key]; |
51 | - if(isset($annotationValue[0]) && $annotationValue[0] === '(' && $annotationValue[strlen($annotationValue) - 1] === ')') { |
|
51 | + if (isset($annotationValue[0]) && $annotationValue[0] === '(' && $annotationValue[strlen($annotationValue) - 1] === ')') { |
|
52 | 52 | $cutString = substr($annotationValue, 1, -1); |
53 | 53 | $cutString = str_replace(' ', '', $cutString); |
54 | 54 | $splittedArray = explode(',', $cutString); |
55 | - foreach($splittedArray as $annotationValues) { |
|
55 | + foreach ($splittedArray as $annotationValues) { |
|
56 | 56 | list($key, $value) = explode('=', $annotationValues); |
57 | 57 | $this->annotations[$annontation][$key] = $value; |
58 | 58 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | - if($param->isOptional()) { |
|
79 | + if ($param->isOptional()) { |
|
80 | 80 | $default = $param->getDefaultValue(); |
81 | 81 | } else { |
82 | 82 | $default = null; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * would return int or null if not existing |
94 | 94 | */ |
95 | 95 | public function getType($parameter) { |
96 | - if(array_key_exists($parameter, $this->types)) { |
|
96 | + if (array_key_exists($parameter, $this->types)) { |
|
97 | 97 | return $this->types[$parameter]; |
98 | 98 | } else { |
99 | 99 | return null; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @return string |
125 | 125 | */ |
126 | 126 | public function getAnnotationParameter($name, $key) { |
127 | - if(isset($this->annotations[$name][$key])) { |
|
127 | + if (isset($this->annotations[$name][$key])) { |
|
128 | 128 | return $this->annotations[$name][$key]; |
129 | 129 | } |
130 | 130 |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | |
152 | 152 | // security checks |
153 | 153 | $isPublicPage = $this->reflector->hasAnnotation('PublicPage'); |
154 | - if(!$isPublicPage) { |
|
155 | - if(!$this->isLoggedIn) { |
|
154 | + if (!$isPublicPage) { |
|
155 | + if (!$this->isLoggedIn) { |
|
156 | 156 | throw new NotLoggedInException(); |
157 | 157 | } |
158 | 158 | |
159 | - if(!$this->reflector->hasAnnotation('NoAdminRequired')) { |
|
160 | - if(!$this->isAdminUser) { |
|
159 | + if (!$this->reflector->hasAnnotation('NoAdminRequired')) { |
|
160 | + if (!$this->isAdminUser) { |
|
161 | 161 | throw new NotAdminException(); |
162 | 162 | } |
163 | 163 | } |
@@ -171,27 +171,27 @@ discard block |
||
171 | 171 | } |
172 | 172 | |
173 | 173 | // Check for strict cookie requirement |
174 | - if($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
175 | - if(!$this->request->passesStrictCookieCheck()) { |
|
174 | + if ($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
175 | + if (!$this->request->passesStrictCookieCheck()) { |
|
176 | 176 | throw new StrictCookieMissingException(); |
177 | 177 | } |
178 | 178 | } |
179 | 179 | // CSRF check - also registers the CSRF token since the session may be closed later |
180 | 180 | Util::callRegister(); |
181 | - if(!$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
181 | + if (!$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
182 | 182 | /* |
183 | 183 | * Only allow the CSRF check to fail on OCS Requests. This kind of |
184 | 184 | * hacks around that we have no full token auth in place yet and we |
185 | 185 | * do want to offer CSRF checks for web requests. |
186 | 186 | */ |
187 | - if(!$this->request->passesCSRFCheck() && !( |
|
187 | + if (!$this->request->passesCSRFCheck() && !( |
|
188 | 188 | $controller instanceof OCSController && |
189 | 189 | $this->request->getHeader('OCS-APIREQUEST') === 'true')) { |
190 | 190 | throw new CrossSiteRequestForgeryException(); |
191 | 191 | } |
192 | 192 | } |
193 | 193 | |
194 | - if($this->reflector->hasAnnotation('BruteForceProtection')) { |
|
194 | + if ($this->reflector->hasAnnotation('BruteForceProtection')) { |
|
195 | 195 | $action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action'); |
196 | 196 | $this->throttler->sleepDelay($this->request->getRemoteAddress(), $action); |
197 | 197 | $this->throttler->registerAttempt($action, $this->request->getRemoteAddress()); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * The getAppPath() check is here since components such as settings also use the AppFramework and |
204 | 204 | * therefore won't pass this check. |
205 | 205 | */ |
206 | - if(\OC_App::getAppPath($this->appName) !== false && !\OC_App::isEnabled($this->appName)) { |
|
206 | + if (\OC_App::getAppPath($this->appName) !== false && !\OC_App::isEnabled($this->appName)) { |
|
207 | 207 | throw new AppNotEnabledException(); |
208 | 208 | } |
209 | 209 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | $defaultPolicy = $this->contentSecurityPolicyManager->getDefaultPolicy(); |
229 | 229 | $defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy); |
230 | 230 | |
231 | - if($this->cspNonceManager->browserSupportsCspV3()) { |
|
231 | + if ($this->cspNonceManager->browserSupportsCspV3()) { |
|
232 | 232 | $defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue()); |
233 | 233 | } |
234 | 234 | |
@@ -248,17 +248,17 @@ discard block |
||
248 | 248 | * @return Response a Response object or null in case that the exception could not be handled |
249 | 249 | */ |
250 | 250 | public function afterException($controller, $methodName, \Exception $exception) { |
251 | - if($exception instanceof SecurityException) { |
|
252 | - if($exception instanceof StrictCookieMissingException) { |
|
251 | + if ($exception instanceof SecurityException) { |
|
252 | + if ($exception instanceof StrictCookieMissingException) { |
|
253 | 253 | return new RedirectResponse(\OC::$WEBROOT); |
254 | 254 | } |
255 | - if (stripos($this->request->getHeader('Accept'),'html') === false) { |
|
255 | + if (stripos($this->request->getHeader('Accept'), 'html') === false) { |
|
256 | 256 | $response = new JSONResponse( |
257 | 257 | array('message' => $exception->getMessage()), |
258 | 258 | $exception->getCode() |
259 | 259 | ); |
260 | 260 | } else { |
261 | - if($exception instanceof NotLoggedInException) { |
|
261 | + if ($exception instanceof NotLoggedInException) { |
|
262 | 262 | $url = $this->urlGenerator->linkToRoute( |
263 | 263 | 'core.login.showLoginForm', |
264 | 264 | [ |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | $anonPeriod = $this->reflector->getAnnotationParameter('AnonRateThrottle', 'period'); |
85 | 85 | $userLimit = $this->reflector->getAnnotationParameter('UserRateThrottle', 'limit'); |
86 | 86 | $userPeriod = $this->reflector->getAnnotationParameter('UserRateThrottle', 'period'); |
87 | - $rateLimitIdentifier = get_class($controller) . '::' . $methodName; |
|
88 | - if($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) { |
|
87 | + $rateLimitIdentifier = get_class($controller).'::'.$methodName; |
|
88 | + if ($userLimit !== '' && $userPeriod !== '' && $this->userSession->isLoggedIn()) { |
|
89 | 89 | $this->limiter->registerUserRequest( |
90 | 90 | $rateLimitIdentifier, |
91 | 91 | $userLimit, |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | * {@inheritDoc} |
107 | 107 | */ |
108 | 108 | public function afterException($controller, $methodName, \Exception $exception) { |
109 | - if($exception instanceof RateLimitExceededException) { |
|
110 | - if (stripos($this->request->getHeader('Accept'),'html') === false) { |
|
109 | + if ($exception instanceof RateLimitExceededException) { |
|
110 | + if (stripos($this->request->getHeader('Accept'), 'html') === false) { |
|
111 | 111 | $response = new JSONResponse( |
112 | 112 | [ |
113 | 113 | 'message' => $exception->getMessage(), |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @param array $urlParams |
77 | 77 | * @param ServerContainer $server |
78 | 78 | */ |
79 | - public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
79 | + public function __construct($appName, $urlParams = array(), ServerContainer $server = null) { |
|
80 | 80 | parent::__construct(); |
81 | 81 | $this['AppName'] = $appName; |
82 | 82 | $this['urlParams'] = $urlParams; |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * Core services |
98 | 98 | */ |
99 | - $this->registerService(IOutput::class, function($c){ |
|
99 | + $this->registerService(IOutput::class, function($c) { |
|
100 | 100 | return new Output($this->getServer()->getWebRoot()); |
101 | 101 | }); |
102 | 102 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | return $this->getServer()->getUserFolder(); |
105 | 105 | }); |
106 | 106 | |
107 | - $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
107 | + $this->registerService(IAppData::class, function(SimpleContainer $c) { |
|
108 | 108 | return $this->getServer()->getAppDataDir($c->query('AppName')); |
109 | 109 | }); |
110 | 110 | |
@@ -125,25 +125,25 @@ discard block |
||
125 | 125 | |
126 | 126 | $this->registerAlias(\OC\User\Session::class, \OCP\IUserSession::class); |
127 | 127 | |
128 | - $this->registerService(IServerContainer::class, function ($c) { |
|
128 | + $this->registerService(IServerContainer::class, function($c) { |
|
129 | 129 | return $this->getServer(); |
130 | 130 | }); |
131 | 131 | $this->registerAlias('ServerContainer', IServerContainer::class); |
132 | 132 | |
133 | - $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
133 | + $this->registerService(\OCP\WorkflowEngine\IManager::class, function($c) { |
|
134 | 134 | return $c->query('OCA\WorkflowEngine\Manager'); |
135 | 135 | }); |
136 | 136 | |
137 | - $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
137 | + $this->registerService(\OCP\AppFramework\IAppContainer::class, function($c) { |
|
138 | 138 | return $c; |
139 | 139 | }); |
140 | 140 | |
141 | 141 | // commonly used attributes |
142 | - $this->registerService('UserId', function ($c) { |
|
142 | + $this->registerService('UserId', function($c) { |
|
143 | 143 | return $c->query('OCP\\IUserSession')->getSession()->get('user_id'); |
144 | 144 | }); |
145 | 145 | |
146 | - $this->registerService('WebRoot', function ($c) { |
|
146 | + $this->registerService('WebRoot', function($c) { |
|
147 | 147 | return $c->query('ServerContainer')->getWebRoot(); |
148 | 148 | }); |
149 | 149 | |
@@ -151,11 +151,11 @@ discard block |
||
151 | 151 | return Util::getDefaultEmailAddress('no-reply'); |
152 | 152 | }); |
153 | 153 | |
154 | - $this->registerService('OC_Defaults', function ($c) { |
|
154 | + $this->registerService('OC_Defaults', function($c) { |
|
155 | 155 | return $c->getServer()->getThemingDefaults(); |
156 | 156 | }); |
157 | 157 | |
158 | - $this->registerService('OCP\Encryption\IManager', function ($c) { |
|
158 | + $this->registerService('OCP\Encryption\IManager', function($c) { |
|
159 | 159 | return $this->getServer()->getEncryptionManager(); |
160 | 160 | }); |
161 | 161 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | return $c->query(Validator::class); |
164 | 164 | }); |
165 | 165 | |
166 | - $this->registerService(\OC\Security\IdentityProof\Manager::class, function ($c) { |
|
166 | + $this->registerService(\OC\Security\IdentityProof\Manager::class, function($c) { |
|
167 | 167 | return new \OC\Security\IdentityProof\Manager( |
168 | 168 | $this->getServer()->getAppDataDir('identityproof'), |
169 | 169 | $this->getServer()->getCrypto() |
@@ -173,15 +173,15 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * App Framework APIs |
175 | 175 | */ |
176 | - $this->registerService('API', function($c){ |
|
176 | + $this->registerService('API', function($c) { |
|
177 | 177 | $c->query('OCP\\ILogger')->debug( |
178 | - 'Accessing the API class is deprecated! Use the appropriate ' . |
|
178 | + 'Accessing the API class is deprecated! Use the appropriate '. |
|
179 | 179 | 'services instead!' |
180 | 180 | ); |
181 | 181 | return new API($c['AppName']); |
182 | 182 | }); |
183 | 183 | |
184 | - $this->registerService('Protocol', function($c){ |
|
184 | + $this->registerService('Protocol', function($c) { |
|
185 | 185 | /** @var \OC\Server $server */ |
186 | 186 | $server = $c->query('ServerContainer'); |
187 | 187 | $protocol = $server->getRequest()->getHttpProtocol(); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | ); |
260 | 260 | }); |
261 | 261 | |
262 | - $this->registerService('TwoFactorMiddleware', function (SimpleContainer $c) use ($app) { |
|
262 | + $this->registerService('TwoFactorMiddleware', function(SimpleContainer $c) use ($app) { |
|
263 | 263 | $twoFactorManager = $c->getServer()->getTwoFactorAuthManager(); |
264 | 264 | $userSession = $app->getServer()->getUserSession(); |
265 | 265 | $session = $app->getServer()->getSession(); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | return new TwoFactorMiddleware($twoFactorManager, $userSession, $session, $urlGenerator, $reflector, $request); |
270 | 270 | }); |
271 | 271 | |
272 | - $this->registerService('OCSMiddleware', function (SimpleContainer $c) { |
|
272 | + $this->registerService('OCSMiddleware', function(SimpleContainer $c) { |
|
273 | 273 | return new OCSMiddleware( |
274 | 274 | $c['Request'] |
275 | 275 | ); |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $dispatcher->registerMiddleWare($c['TwoFactorMiddleware']); |
285 | 285 | $dispatcher->registerMiddleware($c['RateLimitingMiddleware']); |
286 | 286 | |
287 | - foreach($middleWares as $middleWare) { |
|
287 | + foreach ($middleWares as $middleWare) { |
|
288 | 288 | $dispatcher->registerMiddleware($c[$middleWare]); |
289 | 289 | } |
290 | 290 | |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | * @return mixed |
357 | 357 | */ |
358 | 358 | function log($message, $level) { |
359 | - switch($level){ |
|
359 | + switch ($level) { |
|
360 | 360 | case 'debug': |
361 | 361 | $level = \OCP\Util::DEBUG; |
362 | 362 | break; |
@@ -415,12 +415,12 @@ discard block |
||
415 | 415 | return parent::query($name); |
416 | 416 | } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
417 | 417 | return parent::query($name); |
418 | - } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
418 | + } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']).'\\') === 0) { |
|
419 | 419 | return parent::query($name); |
420 | 420 | } |
421 | 421 | } |
422 | 422 | |
423 | - throw new QueryException('Could not resolve ' . $name . '!' . |
|
423 | + throw new QueryException('Could not resolve '.$name.'!'. |
|
424 | 424 | ' Class can not be instantiated'); |
425 | 425 | } |
426 | 426 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | */ |
55 | 55 | private function hash($methodIdentifier, |
56 | 56 | $userIdentifier) { |
57 | - return hash('sha512', $methodIdentifier . $userIdentifier); |
|
57 | + return hash('sha512', $methodIdentifier.$userIdentifier); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | private function getExistingAttempts($identifier) { |
65 | 65 | $cachedAttempts = json_decode($this->cache->get($identifier), true); |
66 | - if(is_array($cachedAttempts)) { |
|
66 | + if (is_array($cachedAttempts)) { |
|
67 | 67 | return $cachedAttempts; |
68 | 68 | } |
69 | 69 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $currentTime = $this->timeFactory->getTime(); |
84 | 84 | /** @var array $existingAttempts */ |
85 | 85 | foreach ($existingAttempts as $attempt) { |
86 | - if(($attempt + $seconds) > $currentTime) { |
|
86 | + if (($attempt + $seconds) > $currentTime) { |
|
87 | 87 | $count++; |
88 | 88 | } |
89 | 89 | } |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | |
104 | 104 | // Unset all attempts older than $period |
105 | 105 | foreach ($existingAttempts as $key => $attempt) { |
106 | - if(($attempt + $period) < $currentTime) { |
|
106 | + if (($attempt + $period) < $currentTime) { |
|
107 | 107 | unset($existingAttempts[$key]); |
108 | 108 | } |
109 | 109 | } |
110 | 110 | $existingAttempts = array_values($existingAttempts); |
111 | 111 | |
112 | 112 | // Store the new attempt |
113 | - $existingAttempts[] = (string)$currentTime; |
|
113 | + $existingAttempts[] = (string) $currentTime; |
|
114 | 114 | $this->cache->set($identifier, json_encode($existingAttempts)); |
115 | 115 | } |
116 | 116 | } |