@@ -72,8 +72,8 @@ |
||
72 | 72 | |
73 | 73 | $convertedAddresses = []; |
74 | 74 | |
75 | - foreach($addresses as $email => $readableName) { |
|
76 | - if(!is_numeric($email)) { |
|
75 | + foreach ($addresses as $email => $readableName) { |
|
76 | + if (!is_numeric($email)) { |
|
77 | 77 | list($name, $domain) = explode('@', $email, 2); |
78 | 78 | $domain = idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46); |
79 | 79 | $convertedAddresses[$name.'@'.$domain] = $readableName; |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | |
403 | 403 | $this->htmlBody .= vsprintf($this->heading, [htmlspecialchars($title)]); |
404 | 404 | if ($plainTitle !== false) { |
405 | - $this->plainBody .= $plainTitle . PHP_EOL . PHP_EOL; |
|
405 | + $this->plainBody .= $plainTitle.PHP_EOL.PHP_EOL; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | |
439 | 439 | $this->htmlBody .= vsprintf($this->bodyText, [$text]); |
440 | 440 | if ($plainText !== false) { |
441 | - $this->plainBody .= $plainText . PHP_EOL . PHP_EOL; |
|
441 | + $this->plainBody .= $plainText.PHP_EOL.PHP_EOL; |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | |
@@ -468,18 +468,18 @@ discard block |
||
468 | 468 | |
469 | 469 | $htmlText = $text; |
470 | 470 | if ($metaInfo) { |
471 | - $htmlText = '<em style="color:#777;">' . $metaInfo . '</em><br>' . $htmlText; |
|
471 | + $htmlText = '<em style="color:#777;">'.$metaInfo.'</em><br>'.$htmlText; |
|
472 | 472 | } |
473 | 473 | if ($icon !== '') { |
474 | - $icon = '<img src="' . htmlspecialchars($icon) . '" alt="•">'; |
|
474 | + $icon = '<img src="'.htmlspecialchars($icon).'" alt="•">'; |
|
475 | 475 | } else { |
476 | 476 | $icon = '•'; |
477 | 477 | } |
478 | 478 | $this->htmlBody .= vsprintf($this->listItem, [$icon, $htmlText]); |
479 | 479 | if ($plainText !== false) { |
480 | - $this->plainBody .= ' * ' . $plainText; |
|
480 | + $this->plainBody .= ' * '.$plainText; |
|
481 | 481 | if ($plainMetaInfo !== false) { |
482 | - $this->plainBody .= ' (' . $plainMetaInfo . ')'; |
|
482 | + $this->plainBody .= ' ('.$plainMetaInfo.')'; |
|
483 | 483 | } |
484 | 484 | $this->plainBody .= PHP_EOL; |
485 | 485 | } |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | $textColor = $this->themingDefaults->getTextColorPrimary(); |
541 | 541 | |
542 | 542 | $this->htmlBody .= vsprintf($this->buttonGroup, [$color, $color, $urlLeft, $color, $textColor, $textColor, $textLeft, $urlRight, $textRight]); |
543 | - $this->plainBody .= $plainTextLeft . ': ' . $urlLeft . PHP_EOL; |
|
544 | - $this->plainBody .= $plainTextRight . ': ' . $urlRight . PHP_EOL . PHP_EOL; |
|
543 | + $this->plainBody .= $plainTextLeft.': '.$urlLeft.PHP_EOL; |
|
544 | + $this->plainBody .= $plainTextRight.': '.$urlRight.PHP_EOL.PHP_EOL; |
|
545 | 545 | |
546 | 546 | } |
547 | 547 | |
@@ -573,10 +573,10 @@ discard block |
||
573 | 573 | $this->htmlBody .= vsprintf($this->button, [$color, $color, $url, $color, $textColor, $textColor, $text]); |
574 | 574 | |
575 | 575 | if ($plainText !== false) { |
576 | - $this->plainBody .= $plainText . ': '; |
|
576 | + $this->plainBody .= $plainText.': '; |
|
577 | 577 | } |
578 | 578 | |
579 | - $this->plainBody .= $url . PHP_EOL; |
|
579 | + $this->plainBody .= $url.PHP_EOL; |
|
580 | 580 | |
581 | 581 | } |
582 | 582 | |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | * @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used |
601 | 601 | */ |
602 | 602 | public function addFooter(string $text = '') { |
603 | - if($text === '') { |
|
604 | - $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
603 | + if ($text === '') { |
|
604 | + $text = $this->themingDefaults->getName().' - '.$this->themingDefaults->getSlogan().'<br>'.$this->l10n->t('This is an automatically sent email, please do not reply.'); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | if ($this->footerAdded) { |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | |
614 | 614 | $this->htmlBody .= vsprintf($this->footer, [$text]); |
615 | 615 | $this->htmlBody .= $this->tail; |
616 | - $this->plainBody .= PHP_EOL . '-- ' . PHP_EOL; |
|
616 | + $this->plainBody .= PHP_EOL.'-- '.PHP_EOL; |
|
617 | 617 | $this->plainBody .= str_replace('<br>', PHP_EOL, $text); |
618 | 618 | } |
619 | 619 |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | } |
76 | 76 | $this->configured = true; |
77 | 77 | |
78 | - $this->stack->push(Middleware::mapRequest(function (RequestInterface $request) { |
|
78 | + $this->stack->push(Middleware::mapRequest(function(RequestInterface $request) { |
|
79 | 79 | return $request |
80 | 80 | ->withHeader('User-Agent', 'Nextcloud Server Crawler'); |
81 | 81 | })); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if ($this->config->getSystemValue('installed', false)) { |
103 | 103 | return $this->certificateManager->getAbsoluteBundlePath(null); |
104 | 104 | } else { |
105 | - return \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'; |
|
105 | + return \OC::$SERVERROOT.'/resources/config/ca-bundle.crt'; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $proxyUri = ''; |
119 | 119 | |
120 | 120 | if ($proxyUserPwd !== null) { |
121 | - $proxyUri .= $proxyUserPwd . '@'; |
|
121 | + $proxyUri .= $proxyUserPwd.'@'; |
|
122 | 122 | } |
123 | 123 | if ($proxyHost !== null) { |
124 | 124 | $proxyUri .= $proxyHost; |
@@ -80,7 +80,7 @@ |
||
80 | 80 | */ |
81 | 81 | public function getCloudId(string $user, string $remote): ICloudId { |
82 | 82 | // TODO check what the correct url is for remote (asking the remote) |
83 | - return new CloudId($user. '@' . $remote, $user, $remote); |
|
83 | + return new CloudId($user.'@'.$remote, $user, $remote); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | // exception and creates a response. If no response is created, it is |
103 | 103 | // assumed that theres no middleware who can handle it and the error is |
104 | 104 | // thrown again |
105 | - } catch(\Exception $exception){ |
|
105 | + } catch (\Exception $exception) { |
|
106 | 106 | $response = $this->middlewareDispatcher->afterException( |
107 | 107 | $controller, $methodName, $exception); |
108 | 108 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | // valid types that will be casted |
138 | 138 | $types = ['int', 'integer', 'bool', 'boolean', 'float']; |
139 | 139 | |
140 | - foreach($this->reflector->getParameters() as $param => $default) { |
|
140 | + foreach ($this->reflector->getParameters() as $param => $default) { |
|
141 | 141 | |
142 | 142 | // try to get the parameter from the request object and cast |
143 | 143 | // it to the type annotated in the @param annotation |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | |
147 | 147 | // if this is submitted using GET or a POST form, 'false' should be |
148 | 148 | // converted to false |
149 | - if(($type === 'bool' || $type === 'boolean') && |
|
149 | + if (($type === 'bool' || $type === 'boolean') && |
|
150 | 150 | $value === 'false' && |
151 | 151 | ( |
152 | 152 | $this->request->method === 'GET' || |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | ) { |
157 | 157 | $value = false; |
158 | 158 | |
159 | - } elseif($value !== null && \in_array($type, $types, true)) { |
|
159 | + } elseif ($value !== null && \in_array($type, $types, true)) { |
|
160 | 160 | settype($value, $type); |
161 | 161 | } |
162 | 162 | |
@@ -166,13 +166,13 @@ discard block |
||
166 | 166 | $response = \call_user_func_array([$controller, $methodName], $arguments); |
167 | 167 | |
168 | 168 | // format response |
169 | - if($response instanceof DataResponse || !($response instanceof Response)) { |
|
169 | + if ($response instanceof DataResponse || !($response instanceof Response)) { |
|
170 | 170 | |
171 | 171 | // get format from the url format or request format parameter |
172 | 172 | $format = $this->request->getParam('format'); |
173 | 173 | |
174 | 174 | // if none is given try the first Accept header |
175 | - if($format === null) { |
|
175 | + if ($format === null) { |
|
176 | 176 | $headers = $this->request->getHeader('Accept'); |
177 | 177 | $format = $controller->getResponderByHTTPHeader($headers, null); |
178 | 178 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * Constructor |
55 | 55 | */ |
56 | - public function __construct(){ |
|
56 | + public function __construct() { |
|
57 | 57 | $this->middlewares = []; |
58 | 58 | $this->middlewareCounter = 0; |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * Adds a new middleware |
64 | 64 | * @param Middleware $middleWare the middleware which will be added |
65 | 65 | */ |
66 | - public function registerMiddleware(Middleware $middleWare){ |
|
66 | + public function registerMiddleware(Middleware $middleWare) { |
|
67 | 67 | $this->middlewares[] = $middleWare; |
68 | 68 | } |
69 | 69 | |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | * @param string $methodName the name of the method that will be called on |
86 | 86 | * the controller |
87 | 87 | */ |
88 | - public function beforeController(Controller $controller, string $methodName){ |
|
88 | + public function beforeController(Controller $controller, string $methodName) { |
|
89 | 89 | // we need to count so that we know which middlewares we have to ask in |
90 | 90 | // case there is an exception |
91 | 91 | $middlewareCount = \count($this->middlewares); |
92 | - for($i = 0; $i < $middlewareCount; $i++){ |
|
92 | + for ($i = 0; $i < $middlewareCount; $i++) { |
|
93 | 93 | $this->middlewareCounter++; |
94 | 94 | $middleware = $this->middlewares[$i]; |
95 | 95 | $middleware->beforeController($controller, $methodName); |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | * @throws \Exception the passed in exception if it can't handle it |
114 | 114 | */ |
115 | 115 | public function afterException(Controller $controller, string $methodName, \Exception $exception): Response { |
116 | - for($i=$this->middlewareCounter-1; $i>=0; $i--){ |
|
116 | + for ($i = $this->middlewareCounter - 1; $i >= 0; $i--) { |
|
117 | 117 | $middleware = $this->middlewares[$i]; |
118 | 118 | try { |
119 | 119 | return $middleware->afterException($controller, $methodName, $exception); |
120 | - } catch(\Exception $exception){ |
|
120 | + } catch (\Exception $exception) { |
|
121 | 121 | continue; |
122 | 122 | } |
123 | 123 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @return Response a Response object |
137 | 137 | */ |
138 | 138 | public function afterController(Controller $controller, string $methodName, Response $response): Response { |
139 | - for($i= \count($this->middlewares)-1; $i>=0; $i--){ |
|
139 | + for ($i = \count($this->middlewares) - 1; $i >= 0; $i--) { |
|
140 | 140 | $middleware = $this->middlewares[$i]; |
141 | 141 | $response = $middleware->afterController($controller, $methodName, $response); |
142 | 142 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @return string the output that should be printed |
156 | 156 | */ |
157 | 157 | public function beforeOutput(Controller $controller, string $methodName, string $output): string { |
158 | - for($i= \count($this->middlewares)-1; $i>=0; $i--){ |
|
158 | + for ($i = \count($this->middlewares) - 1; $i >= 0; $i--) { |
|
159 | 159 | $middleware = $this->middlewares[$i]; |
160 | 160 | $output = $middleware->beforeOutput($controller, $methodName, $output); |
161 | 161 | } |
@@ -138,25 +138,25 @@ discard block |
||
138 | 138 | |
139 | 139 | // security checks |
140 | 140 | $isPublicPage = $this->reflector->hasAnnotation('PublicPage'); |
141 | - if(!$isPublicPage) { |
|
142 | - if(!$this->isLoggedIn) { |
|
141 | + if (!$isPublicPage) { |
|
142 | + if (!$this->isLoggedIn) { |
|
143 | 143 | throw new NotLoggedInException(); |
144 | 144 | } |
145 | 145 | |
146 | - if(!$this->reflector->hasAnnotation('NoAdminRequired') && !$this->isAdminUser) { |
|
146 | + if (!$this->reflector->hasAnnotation('NoAdminRequired') && !$this->isAdminUser) { |
|
147 | 147 | throw new NotAdminException($this->l10n->t('Logged in user must be an admin')); |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Check for strict cookie requirement |
152 | - if($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
153 | - if(!$this->request->passesStrictCookieCheck()) { |
|
152 | + if ($this->reflector->hasAnnotation('StrictCookieRequired') || !$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
153 | + if (!$this->request->passesStrictCookieCheck()) { |
|
154 | 154 | throw new StrictCookieMissingException(); |
155 | 155 | } |
156 | 156 | } |
157 | 157 | // CSRF check - also registers the CSRF token since the session may be closed later |
158 | 158 | Util::callRegister(); |
159 | - if(!$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
159 | + if (!$this->reflector->hasAnnotation('NoCSRFRequired')) { |
|
160 | 160 | /* |
161 | 161 | * Only allow the CSRF check to fail on OCS Requests. This kind of |
162 | 162 | * hacks around that we have no full token auth in place yet and we |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | * Additionally we allow Bearer authenticated requests to pass on OCS routes. |
166 | 166 | * This allows oauth apps (e.g. moodle) to use the OCS endpoints |
167 | 167 | */ |
168 | - if(!$this->request->passesCSRFCheck() && !( |
|
168 | + if (!$this->request->passesCSRFCheck() && !( |
|
169 | 169 | $controller instanceof OCSController && ( |
170 | 170 | $this->request->getHeader('OCS-APIREQUEST') === 'true' || |
171 | 171 | strpos($this->request->getHeader('Authorization'), 'Bearer ') === 0 |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $defaultPolicy = $this->contentSecurityPolicyManager->getDefaultPolicy(); |
212 | 212 | $defaultPolicy = $this->contentSecurityPolicyManager->mergePolicies($defaultPolicy, $policy); |
213 | 213 | |
214 | - if($this->cspNonceManager->browserSupportsCspV3()) { |
|
214 | + if ($this->cspNonceManager->browserSupportsCspV3()) { |
|
215 | 215 | $defaultPolicy->useJsNonce($this->csrfTokenManager->getToken()->getEncryptedValue()); |
216 | 216 | } |
217 | 217 | |
@@ -231,17 +231,17 @@ discard block |
||
231 | 231 | * @return Response a Response object or null in case that the exception could not be handled |
232 | 232 | */ |
233 | 233 | public function afterException($controller, $methodName, \Exception $exception): Response { |
234 | - if($exception instanceof SecurityException) { |
|
235 | - if($exception instanceof StrictCookieMissingException) { |
|
234 | + if ($exception instanceof SecurityException) { |
|
235 | + if ($exception instanceof StrictCookieMissingException) { |
|
236 | 236 | return new RedirectResponse(\OC::$WEBROOT); |
237 | 237 | } |
238 | - if (stripos($this->request->getHeader('Accept'),'html') === false) { |
|
238 | + if (stripos($this->request->getHeader('Accept'), 'html') === false) { |
|
239 | 239 | $response = new JSONResponse( |
240 | 240 | ['message' => $exception->getMessage()], |
241 | 241 | $exception->getCode() |
242 | 242 | ); |
243 | 243 | } else { |
244 | - if($exception instanceof NotLoggedInException) { |
|
244 | + if ($exception instanceof NotLoggedInException) { |
|
245 | 245 | $params = []; |
246 | 246 | if (isset($this->request->server['REQUEST_URI'])) { |
247 | 247 | $params['redirect_url'] = $this->request->server['REQUEST_URI']; |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * the transformed app id, defaults to OCA\ |
57 | 57 | * @return string the starting namespace for the app |
58 | 58 | */ |
59 | - public static function buildAppNamespace(string $appId, string $topNamespace='OCA\\'): string { |
|
59 | + public static function buildAppNamespace(string $appId, string $topNamespace = 'OCA\\'): string { |
|
60 | 60 | // Hit the cache! |
61 | 61 | if (isset(self::$nameSpaceCache[$appId])) { |
62 | - return $topNamespace . self::$nameSpaceCache[$appId]; |
|
62 | + return $topNamespace.self::$nameSpaceCache[$appId]; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | $appInfo = \OC_App::getAppInfo($appId); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | self::$nameSpaceCache[$appId] = ucfirst($appId); |
71 | 71 | } |
72 | 72 | |
73 | - return $topNamespace . self::$nameSpaceCache[$appId]; |
|
73 | + return $topNamespace.self::$nameSpaceCache[$appId]; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | // first try $controllerName then go for \OCA\AppName\Controller\$controllerName |
94 | 94 | try { |
95 | 95 | $controller = $container->query($controllerName); |
96 | - } catch(QueryException $e) { |
|
96 | + } catch (QueryException $e) { |
|
97 | 97 | if ($appName === 'core') { |
98 | 98 | $appNameSpace = 'OC\\Core'; |
99 | 99 | } else if ($appName === 'settings') { |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | } else { |
102 | 102 | $appNameSpace = self::buildAppNamespace($appName); |
103 | 103 | } |
104 | - $controllerName = $appNameSpace . '\\Controller\\' . $controllerName; |
|
104 | + $controllerName = $appNameSpace.'\\Controller\\'.$controllerName; |
|
105 | 105 | $controller = $container->query($controllerName); |
106 | 106 | } |
107 | 107 | |
@@ -119,17 +119,17 @@ discard block |
||
119 | 119 | |
120 | 120 | $io = $container[IOutput::class]; |
121 | 121 | |
122 | - if(!is_null($httpHeaders)) { |
|
122 | + if (!is_null($httpHeaders)) { |
|
123 | 123 | $io->setHeader($httpHeaders); |
124 | 124 | } |
125 | 125 | |
126 | - foreach($responseHeaders as $name => $value) { |
|
127 | - $io->setHeader($name . ': ' . $value); |
|
126 | + foreach ($responseHeaders as $name => $value) { |
|
127 | + $io->setHeader($name.': '.$value); |
|
128 | 128 | } |
129 | 129 | |
130 | - foreach($responseCookies as $name => $value) { |
|
130 | + foreach ($responseCookies as $name => $value) { |
|
131 | 131 | $expireDate = null; |
132 | - if($value['expireDate'] instanceof \DateTime) { |
|
132 | + if ($value['expireDate'] instanceof \DateTime) { |
|
133 | 133 | $expireDate = $value['expireDate']->getTimestamp(); |
134 | 134 | } |
135 | 135 | $io->setCookie( |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | if ($response instanceof ICallbackResponse) { |
154 | 154 | $response->callback($io); |
155 | 155 | } else if (!is_null($output)) { |
156 | - $io->setHeader('Content-Length: ' . strlen($output)); |
|
156 | + $io->setHeader('Content-Length: '.strlen($output)); |
|
157 | 157 | $io->setOutput($output); |
158 | 158 | } |
159 | 159 | } |
@@ -173,14 +173,14 @@ discard block |
||
173 | 173 | * @param DIContainer $container an instance of a pimple container. |
174 | 174 | */ |
175 | 175 | public static function part(string $controllerName, string $methodName, array $urlParams, |
176 | - DIContainer $container){ |
|
176 | + DIContainer $container) { |
|
177 | 177 | |
178 | 178 | $container['urlParams'] = $urlParams; |
179 | 179 | $controller = $container[$controllerName]; |
180 | 180 | |
181 | 181 | $dispatcher = $container['Dispatcher']; |
182 | 182 | |
183 | - list(, , $output) = $dispatcher->dispatch($controller, $methodName); |
|
183 | + list(,, $output) = $dispatcher->dispatch($controller, $methodName); |
|
184 | 184 | return $output; |
185 | 185 | } |
186 | 186 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param object $object an object or classname |
44 | 44 | * @param string $method the method which we want to inspect |
45 | 45 | */ |
46 | - public function reflect($object, string $method){ |
|
46 | + public function reflect($object, string $method) { |
|
47 | 47 | $reflection = new \ReflectionMethod($object, $method); |
48 | 48 | $docs = $reflection->getDocComment(); |
49 | 49 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | $default = null; |
85 | - if($param->isOptional()) { |
|
85 | + if ($param->isOptional()) { |
|
86 | 86 | $default = $param->getDefaultValue(); |
87 | 87 | } |
88 | 88 | $this->parameters[$param->name] = $default; |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * would return int or null if not existing |
98 | 98 | */ |
99 | 99 | public function getType(string $parameter) { |
100 | - if(array_key_exists($parameter, $this->types)) { |
|
100 | + if (array_key_exists($parameter, $this->types)) { |
|
101 | 101 | return $this->types[$parameter]; |
102 | 102 | } |
103 | 103 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return string |
129 | 129 | */ |
130 | 130 | public function getAnnotationParameter(string $name, string $key): string { |
131 | - if(isset($this->annotations[$name][$key])) { |
|
131 | + if (isset($this->annotations[$name][$key])) { |
|
132 | 132 | return $this->annotations[$name][$key]; |
133 | 133 | } |
134 | 134 |