summaryrefslogtreecommitdiffstats
path: root/lib/private/AppFramework/Http/Dispatcher.php
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 14:19:56 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 14:19:56 +0200
commitcaff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch)
tree186d494c2aea5dea7255d3584ef5d595fc6e6194 /lib/private/AppFramework/Http/Dispatcher.php
parentedf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff)
downloadnextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.tar.gz
nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.zip
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds unified formatting for control structures like if and loops as well as classes, their methods and anonymous functions. This basically forces the constructs to start on the same line. This is not exactly what PSR2 wants, but I think we can have a few exceptions with "our" style. The starting of braces on the same line is pracrically standard for our code. This also removes and empty lines from method/function bodies at the beginning and end. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/AppFramework/Http/Dispatcher.php')
-rw-r--r--lib/private/AppFramework/Http/Dispatcher.php16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/private/AppFramework/Http/Dispatcher.php b/lib/private/AppFramework/Http/Dispatcher.php
index 33ce8741acf..f1871e84c08 100644
--- a/lib/private/AppFramework/Http/Dispatcher.php
+++ b/lib/private/AppFramework/Http/Dispatcher.php
@@ -102,10 +102,10 @@ class Dispatcher {
// exception and creates a response. If no response is created, it is
// assumed that theres no middleware who can handle it and the error is
// thrown again
- } catch(\Exception $exception){
+ } catch (\Exception $exception) {
$response = $this->middlewareDispatcher->afterException(
$controller, $methodName, $exception);
- } catch(\Throwable $throwable) {
+ } catch (\Throwable $throwable) {
$exception = new \Exception($throwable->getMessage(), $throwable->getCode(), $throwable);
$response = $this->middlewareDispatcher->afterException(
$controller, $methodName, $exception);
@@ -141,7 +141,7 @@ class Dispatcher {
// valid types that will be casted
$types = ['int', 'integer', 'bool', 'boolean', 'float'];
- foreach($this->reflector->getParameters() as $param => $default) {
+ foreach ($this->reflector->getParameters() as $param => $default) {
// try to get the parameter from the request object and cast
// it to the type annotated in the @param annotation
@@ -150,7 +150,7 @@ class Dispatcher {
// if this is submitted using GET or a POST form, 'false' should be
// converted to false
- if(($type === 'bool' || $type === 'boolean') &&
+ if (($type === 'bool' || $type === 'boolean') &&
$value === 'false' &&
(
$this->request->method === 'GET' ||
@@ -159,8 +159,7 @@ class Dispatcher {
)
) {
$value = false;
-
- } elseif($value !== null && \in_array($type, $types, true)) {
+ } elseif ($value !== null && \in_array($type, $types, true)) {
settype($value, $type);
}
@@ -170,13 +169,13 @@ class Dispatcher {
$response = \call_user_func_array([$controller, $methodName], $arguments);
// format response
- if($response instanceof DataResponse || !($response instanceof Response)) {
+ if ($response instanceof DataResponse || !($response instanceof Response)) {
// get format from the url format or request format parameter
$format = $this->request->getParam('format');
// if none is given try the first Accept header
- if($format === null) {
+ if ($format === null) {
$headers = $this->request->getHeader('Accept');
$format = $controller->getResponderByHTTPHeader($headers, null);
}
@@ -190,5 +189,4 @@ class Dispatcher {
return $response;
}
-
}