@@ -49,7 +49,7 @@ |
||
49 | 49 | protected function setSubjects(IEvent $event, $subject, array $parameters) { |
50 | 50 | $placeholders = $replacements = []; |
51 | 51 | foreach ($parameters as $placeholder => $parameter) { |
52 | - $placeholders[] = '{' . $placeholder . '}'; |
|
52 | + $placeholders[] = '{'.$placeholder.'}'; |
|
53 | 53 | $replacements[] = $parameter['name']; |
54 | 54 | } |
55 | 55 |
@@ -39,22 +39,22 @@ |
||
39 | 39 | } |
40 | 40 | |
41 | 41 | public function md5($input) { |
42 | - return new QueryFunction('MD5(' . $this->helper->quoteColumnName($input) . ')'); |
|
42 | + return new QueryFunction('MD5('.$this->helper->quoteColumnName($input).')'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | public function concat($x, $y) { |
46 | - return new QueryFunction('CONCAT(' . $this->helper->quoteColumnName($x) . ', ' . $this->helper->quoteColumnName($y) . ')'); |
|
46 | + return new QueryFunction('CONCAT('.$this->helper->quoteColumnName($x).', '.$this->helper->quoteColumnName($y).')'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | public function substring($input, $start, $length = null) { |
50 | 50 | if ($length) { |
51 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ', ' . $this->helper->quoteColumnName($length) . ')'); |
|
51 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).', '.$this->helper->quoteColumnName($length).')'); |
|
52 | 52 | } else { |
53 | - return new QueryFunction('SUBSTR(' . $this->helper->quoteColumnName($input) . ', ' . $this->helper->quoteColumnName($start) . ')'); |
|
53 | + return new QueryFunction('SUBSTR('.$this->helper->quoteColumnName($input).', '.$this->helper->quoteColumnName($start).')'); |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | 57 | public function sum($field) { |
58 | - return new QueryFunction('SUM(' . $this->helper->quoteColumnName($field) . ')'); |
|
58 | + return new QueryFunction('SUM('.$this->helper->quoteColumnName($field).')'); |
|
59 | 59 | } |
60 | 60 | } |
@@ -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 | } |
@@ -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 |
@@ -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(), |
@@ -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 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | public function beforeController($controller, $methodName) { |
62 | 62 | parent::beforeController($controller, $methodName); |
63 | 63 | |
64 | - if($this->reflector->hasAnnotation('BruteForceProtection')) { |
|
64 | + if ($this->reflector->hasAnnotation('BruteForceProtection')) { |
|
65 | 65 | $action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action'); |
66 | 66 | $this->throttler->sleepDelay($this->request->getRemoteAddress(), $action); |
67 | 67 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * {@inheritDoc} |
72 | 72 | */ |
73 | 73 | public function afterController($controller, $methodName, Response $response) { |
74 | - if($this->reflector->hasAnnotation('BruteForceProtection') && $response->isThrottled()) { |
|
74 | + if ($this->reflector->hasAnnotation('BruteForceProtection') && $response->isThrottled()) { |
|
75 | 75 | $action = $this->reflector->getAnnotationParameter('BruteForceProtection', 'action'); |
76 | 76 | $ip = $this->request->getRemoteAddress(); |
77 | 77 | $this->throttler->sleepDelay($ip, $action); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $storedPassword = $share->getPassword(); |
148 | 148 | $authenticated = $this->session->get('public_link_authenticated') === $share->getId() || |
149 | 149 | $this->shareManager->checkPassword($share, $password); |
150 | - if (!empty($storedPassword) && !$authenticated ) { |
|
150 | + if (!empty($storedPassword) && !$authenticated) { |
|
151 | 151 | $response = new JSONResponse( |
152 | 152 | ['message' => 'No permission to access the share'], |
153 | 153 | Http::STATUS_BAD_REQUEST |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | $httpClient = $this->clientService->newClient(); |
192 | 192 | |
193 | 193 | try { |
194 | - $response = $httpClient->post($remote . '/index.php/apps/federatedfilesharing/createFederatedShare', |
|
194 | + $response = $httpClient->post($remote.'/index.php/apps/federatedfilesharing/createFederatedShare', |
|
195 | 195 | [ |
196 | 196 | 'body' => |
197 | 197 | [ |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | // note: checkStorageAvailability will already remove the invalid share |
286 | 286 | Util::writeLog( |
287 | 287 | 'federatedfilesharing', |
288 | - 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), |
|
288 | + 'Invalid remote storage: '.get_class($e).': '.$e->getMessage(), |
|
289 | 289 | Util::DEBUG |
290 | 290 | ); |
291 | 291 | return new JSONResponse(['message' => $this->l->t('Could not authenticate to remote share, password might be wrong')], Http::STATUS_BAD_REQUEST); |
292 | 292 | } catch (\Exception $e) { |
293 | 293 | Util::writeLog( |
294 | 294 | 'federatedfilesharing', |
295 | - 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), |
|
295 | + 'Invalid remote storage: '.get_class($e).': '.$e->getMessage(), |
|
296 | 296 | Util::DEBUG |
297 | 297 | ); |
298 | 298 | $externalManager->removeShare($mount->getMountPoint()); |
@@ -311,14 +311,14 @@ discard block |
||
311 | 311 | } catch (StorageInvalidException $e) { |
312 | 312 | Util::writeLog( |
313 | 313 | 'federatedfilesharing', |
314 | - 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), |
|
314 | + 'Invalid remote storage: '.get_class($e).': '.$e->getMessage(), |
|
315 | 315 | Util::DEBUG |
316 | 316 | ); |
317 | 317 | return new JSONResponse(['message' => $this->l->t('Storage not valid')], Http::STATUS_BAD_REQUEST); |
318 | 318 | } catch (\Exception $e) { |
319 | 319 | Util::writeLog( |
320 | 320 | 'federatedfilesharing', |
321 | - 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), |
|
321 | + 'Invalid remote storage: '.get_class($e).': '.$e->getMessage(), |
|
322 | 322 | Util::DEBUG |
323 | 323 | ); |
324 | 324 | return new JSONResponse(['message' => $this->l->t('Couldn\'t add remote share')], Http::STATUS_BAD_REQUEST); |
@@ -198,7 +198,7 @@ |
||
198 | 198 | } catch (NotFoundException $e) { |
199 | 199 | return new DataResponse( |
200 | 200 | [ |
201 | - 'message' => (string)$this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
201 | + 'message' => (string) $this->l10n->t('Storage with ID "%d" not found', array($id)) |
|
202 | 202 | ], |
203 | 203 | Http::STATUS_NOT_FOUND |
204 | 204 | ); |