From caff1023ea72bb2ea94130e18a2a6e2ccf819e5f Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 10 Apr 2020 14:19:56 +0200 Subject: 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 --- lib/private/Security/CSP/ContentSecurityPolicy.php | 1 - lib/private/Security/CSP/ContentSecurityPolicyManager.php | 6 +++--- lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/private/Security/CSP') diff --git a/lib/private/Security/CSP/ContentSecurityPolicy.php b/lib/private/Security/CSP/ContentSecurityPolicy.php index 4db1314e782..4d41bd56206 100644 --- a/lib/private/Security/CSP/ContentSecurityPolicy.php +++ b/lib/private/Security/CSP/ContentSecurityPolicy.php @@ -245,5 +245,4 @@ class ContentSecurityPolicy extends \OCP\AppFramework\Http\ContentSecurityPolicy public function setReportTo(array $reportTo) { $this->reportTo = $reportTo; } - } diff --git a/lib/private/Security/CSP/ContentSecurityPolicyManager.php b/lib/private/Security/CSP/ContentSecurityPolicyManager.php index 9f1a480ccce..4245fdcb2de 100644 --- a/lib/private/Security/CSP/ContentSecurityPolicyManager.php +++ b/lib/private/Security/CSP/ContentSecurityPolicyManager.php @@ -59,7 +59,7 @@ class ContentSecurityPolicyManager implements IContentSecurityPolicyManager { $this->dispatcher->dispatch(AddContentSecurityPolicyEvent::class, $event); $defaultPolicy = new \OC\Security\CSP\ContentSecurityPolicy(); - foreach($this->policies as $policy) { + foreach ($this->policies as $policy) { $defaultPolicy = $this->mergePolicies($defaultPolicy, $policy); } return $defaultPolicy; @@ -74,9 +74,9 @@ class ContentSecurityPolicyManager implements IContentSecurityPolicyManager { */ public function mergePolicies(ContentSecurityPolicy $defaultPolicy, EmptyContentSecurityPolicy $originalPolicy): ContentSecurityPolicy { - foreach((object)(array)$originalPolicy as $name => $value) { + foreach ((object)(array)$originalPolicy as $name => $value) { $setter = 'set'.ucfirst($name); - if(\is_array($value)) { + if (\is_array($value)) { $getter = 'get'.ucfirst($name); $currentValues = \is_array($defaultPolicy->$getter()) ? $defaultPolicy->$getter() : []; $defaultPolicy->$setter(array_values(array_unique(array_merge($currentValues, $value)))); diff --git a/lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php b/lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php index 9dec2907b2f..06f8faece13 100644 --- a/lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php +++ b/lib/private/Security/CSP/ContentSecurityPolicyNonceManager.php @@ -61,7 +61,7 @@ class ContentSecurityPolicyNonceManager { * @return string */ public function getNonce(): string { - if($this->nonce === '') { + if ($this->nonce === '') { if (empty($this->request->server['CSP_NONCE'])) { $this->nonce = base64_encode($this->csrfTokenManager->getToken()->getEncryptedValue()); } else { @@ -86,7 +86,7 @@ class ContentSecurityPolicyNonceManager { '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Version\/(?:1[2-9]|[2-9][0-9])\.[0-9]+(?:\.[0-9]+)? Safari\/[0-9.A-Z]+$/', ]; - if($this->request->isUserAgent($browserWhitelist)) { + if ($this->request->isUserAgent($browserWhitelist)) { return true; } -- cgit v1.2.3