summaryrefslogtreecommitdiffstats
path: root/core/Controller
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 /core/Controller
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 'core/Controller')
-rw-r--r--core/Controller/AutoCompleteController.php2
-rw-r--r--core/Controller/CSRFTokenController.php1
-rw-r--r--core/Controller/ClientFlowLoginController.php14
-rw-r--r--core/Controller/ClientFlowLoginV2Controller.php9
-rw-r--r--core/Controller/CssController.php2
-rw-r--r--core/Controller/JsController.php2
-rw-r--r--core/Controller/LoginController.php1
-rw-r--r--core/Controller/LostController.php8
-rw-r--r--core/Controller/OCSController.php4
-rw-r--r--core/Controller/PreviewController.php4
-rw-r--r--core/Controller/RecommendedAppsController.php1
-rw-r--r--core/Controller/SetupController.php8
-rw-r--r--core/Controller/TwoFactorChallengeController.php1
-rw-r--r--core/Controller/UserController.php1
-rw-r--r--core/Controller/WebAuthnController.php1
-rw-r--r--core/Controller/WhatsNewController.php8
-rw-r--r--core/Controller/WipeController.php1
17 files changed, 28 insertions, 40 deletions
diff --git a/core/Controller/AutoCompleteController.php b/core/Controller/AutoCompleteController.php
index 12414b50f30..31d0a7ab7b3 100644
--- a/core/Controller/AutoCompleteController.php
+++ b/core/Controller/AutoCompleteController.php
@@ -91,7 +91,7 @@ class AutoCompleteController extends Controller {
unset($results['exact']);
$results = array_merge_recursive($exactMatches, $results);
- if($sorter !== null) {
+ if ($sorter !== null) {
$sorters = array_reverse(explode('|', $sorter));
$this->autoCompleteManager->runSorters($sorters, $results, [
'itemType' => $itemType,
diff --git a/core/Controller/CSRFTokenController.php b/core/Controller/CSRFTokenController.php
index b120acbcd5f..9ff389140bd 100644
--- a/core/Controller/CSRFTokenController.php
+++ b/core/Controller/CSRFTokenController.php
@@ -66,5 +66,4 @@ class CSRFTokenController extends Controller {
'token' => $requestToken->getEncryptedValue(),
]);
}
-
}
diff --git a/core/Controller/ClientFlowLoginController.php b/core/Controller/ClientFlowLoginController.php
index 5df6ce5c7b6..dad43fc837a 100644
--- a/core/Controller/ClientFlowLoginController.php
+++ b/core/Controller/ClientFlowLoginController.php
@@ -135,7 +135,7 @@ class ClientFlowLoginController extends Controller {
*/
private function isValidToken($stateToken) {
$currentToken = $this->session->get(self::stateName);
- if(!is_string($stateToken) || !is_string($currentToken)) {
+ if (!is_string($stateToken) || !is_string($currentToken)) {
return false;
}
return hash_equals($currentToken, $stateToken);
@@ -169,7 +169,7 @@ class ClientFlowLoginController extends Controller {
public function showAuthPickerPage($clientIdentifier = '') {
$clientName = $this->getClientName();
$client = null;
- if($clientIdentifier !== '') {
+ if ($clientIdentifier !== '') {
$client = $this->clientMapper->getByIdentifier($clientIdentifier);
$clientName = $client->getName();
}
@@ -237,13 +237,13 @@ class ClientFlowLoginController extends Controller {
*/
public function grantPage($stateToken = '',
$clientIdentifier = '') {
- if(!$this->isValidToken($stateToken)) {
+ if (!$this->isValidToken($stateToken)) {
return $this->stateTokenForbiddenResponse();
}
$clientName = $this->getClientName();
$client = null;
- if($clientIdentifier !== '') {
+ if ($clientIdentifier !== '') {
$client = $this->clientMapper->getByIdentifier($clientIdentifier);
$clientName = $client->getName();
}
@@ -284,7 +284,7 @@ class ClientFlowLoginController extends Controller {
*/
public function generateAppPassword($stateToken,
$clientIdentifier = '') {
- if(!$this->isValidToken($stateToken)) {
+ if (!$this->isValidToken($stateToken)) {
$this->session->remove(self::stateName);
return $this->stateTokenForbiddenResponse();
}
@@ -315,7 +315,7 @@ class ClientFlowLoginController extends Controller {
$clientName = $this->getClientName();
$client = false;
- if($clientIdentifier !== '') {
+ if ($clientIdentifier !== '') {
$client = $this->clientMapper->getByIdentifier($clientIdentifier);
$clientName = $client->getName();
}
@@ -332,7 +332,7 @@ class ClientFlowLoginController extends Controller {
IToken::DO_NOT_REMEMBER
);
- if($client) {
+ if ($client) {
$code = $this->random->generate(128, ISecureRandom::CHAR_UPPER.ISecureRandom::CHAR_LOWER.ISecureRandom::CHAR_DIGITS);
$accessToken = new AccessToken();
$accessToken->setClientId($client->getId());
diff --git a/core/Controller/ClientFlowLoginV2Controller.php b/core/Controller/ClientFlowLoginV2Controller.php
index b5b69972832..43e17c77dde 100644
--- a/core/Controller/ClientFlowLoginV2Controller.php
+++ b/core/Controller/ClientFlowLoginV2Controller.php
@@ -43,7 +43,6 @@ use OCP\IURLGenerator;
use OCP\Security\ISecureRandom;
class ClientFlowLoginV2Controller extends Controller {
-
private const tokenName = 'client.flow.v2.login.token';
private const stateName = 'client.flow.v2.state.token';
@@ -150,7 +149,7 @@ class ClientFlowLoginV2Controller extends Controller {
* @NoSameSiteCookieRequired
*/
public function grantPage(string $stateToken): StandaloneTemplateResponse {
- if(!$this->isValidStateToken($stateToken)) {
+ if (!$this->isValidStateToken($stateToken)) {
return $this->stateTokenForbiddenResponse();
}
@@ -178,7 +177,7 @@ class ClientFlowLoginV2Controller extends Controller {
* @UseSession
*/
public function generateAppPassword(string $stateToken): Response {
- if(!$this->isValidStateToken($stateToken)) {
+ if (!$this->isValidStateToken($stateToken)) {
return $this->stateTokenForbiddenResponse();
}
@@ -241,7 +240,7 @@ class ClientFlowLoginV2Controller extends Controller {
private function isValidStateToken(string $stateToken): bool {
$currentToken = $this->session->get(self::stateName);
- if(!is_string($stateToken) || !is_string($currentToken)) {
+ if (!is_string($stateToken) || !is_string($currentToken)) {
return false;
}
return hash_equals($currentToken, $stateToken);
@@ -266,7 +265,7 @@ class ClientFlowLoginV2Controller extends Controller {
*/
private function getFlowByLoginToken(): LoginFlowV2 {
$currentToken = $this->session->get(self::tokenName);
- if(!is_string($currentToken)) {
+ if (!is_string($currentToken)) {
throw new LoginFlowV2NotFoundException('Login token not set in session');
}
diff --git a/core/Controller/CssController.php b/core/Controller/CssController.php
index 741d4431578..f7368003d55 100644
--- a/core/Controller/CssController.php
+++ b/core/Controller/CssController.php
@@ -75,7 +75,7 @@ class CssController extends Controller {
$folder = $this->appData->getFolder($appName);
$gzip = false;
$file = $this->getFile($folder, $fileName, $gzip);
- } catch(NotFoundException $e) {
+ } catch (NotFoundException $e) {
return new NotFoundResponse();
}
diff --git a/core/Controller/JsController.php b/core/Controller/JsController.php
index 05e7bce3368..730a1cf0cb8 100644
--- a/core/Controller/JsController.php
+++ b/core/Controller/JsController.php
@@ -72,7 +72,7 @@ class JsController extends Controller {
$folder = $this->appData->getFolder($appName);
$gzip = false;
$file = $this->getFile($folder, $fileName, $gzip);
- } catch(NotFoundException $e) {
+ } catch (NotFoundException $e) {
return new NotFoundResponse();
}
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php
index b3f7bb310ba..4813f15f1c5 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -57,7 +57,6 @@ use OCP\IUserSession;
use OCP\Util;
class LoginController extends Controller {
-
const LOGIN_MSG_INVALIDPASSWORD = 'invalidpassword';
const LOGIN_MSG_USERDISABLED = 'userdisabled';
diff --git a/core/Controller/LostController.php b/core/Controller/LostController.php
index e3d59951d4e..0a2e8d6b73d 100644
--- a/core/Controller/LostController.php
+++ b/core/Controller/LostController.php
@@ -195,7 +195,7 @@ class LostController extends Controller {
*/
protected function checkPasswordResetToken($token, $userId) {
$user = $this->userManager->get($userId);
- if($user === null || !$user->isEnabled()) {
+ if ($user === null || !$user->isEnabled()) {
throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
}
@@ -212,7 +212,7 @@ class LostController extends Controller {
}
$splittedToken = explode(':', $decryptedToken);
- if(count($splittedToken) !== 2) {
+ if (count($splittedToken) !== 2) {
throw new \Exception($this->l10n->t('Couldn\'t reset password because the token is invalid'));
}
@@ -318,9 +318,9 @@ class LostController extends Controller {
$this->config->deleteUserValue($userId, 'core', 'lostpassword');
@\OC::$server->getUserSession()->unsetMagicInCookie();
- } catch (HintException $e){
+ } catch (HintException $e) {
return $this->error($e->getHint());
- } catch (\Exception $e){
+ } catch (\Exception $e) {
return $this->error($e->getMessage());
}
diff --git a/core/Controller/OCSController.php b/core/Controller/OCSController.php
index 2ae2e0ee64e..7ed43fc6003 100644
--- a/core/Controller/OCSController.php
+++ b/core/Controller/OCSController.php
@@ -102,7 +102,7 @@ class OCSController extends \OCP\AppFramework\OCSController {
'extendedSupport' => \OCP\Util::hasExtendedSupport()
];
- if($this->userSession->isLoggedIn()) {
+ if ($this->userSession->isLoggedIn()) {
$result['capabilities'] = $this->capabilitiesManager->getCapabilities();
} else {
$result['capabilities'] = $this->capabilitiesManager->getCapabilities(true);
@@ -145,7 +145,7 @@ class OCSController extends \OCP\AppFramework\OCSController {
public function getIdentityProof($cloudId) {
$userObject = $this->userManager->get($cloudId);
- if($userObject !== null) {
+ if ($userObject !== null) {
$key = $this->keyManager->getKey($userObject);
$data = [
'public' => $key->getPublic(),
diff --git a/core/Controller/PreviewController.php b/core/Controller/PreviewController.php
index b92a82028cd..f47104bc533 100644
--- a/core/Controller/PreviewController.php
+++ b/core/Controller/PreviewController.php
@@ -92,7 +92,6 @@ class PreviewController extends Controller {
bool $a = false,
bool $forceIcon = true,
string $mode = 'fill'): Http\Response {
-
if ($file === '' || $x === 0 || $y === 0) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
@@ -127,7 +126,6 @@ class PreviewController extends Controller {
bool $a = false,
bool $forceIcon = true,
string $mode = 'fill') {
-
if ($fileId === -1 || $x === 0 || $y === 0) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
@@ -160,7 +158,6 @@ class PreviewController extends Controller {
bool $a = false,
bool $forceIcon = true,
string $mode) : Http\Response {
-
if (!($node instanceof File) || (!$forceIcon && !$this->preview->isAvailable($node))) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}
@@ -178,6 +175,5 @@ class PreviewController extends Controller {
} catch (\InvalidArgumentException $e) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
}
-
}
}
diff --git a/core/Controller/RecommendedAppsController.php b/core/Controller/RecommendedAppsController.php
index fe3435d9be8..6240aecf43c 100644
--- a/core/Controller/RecommendedAppsController.php
+++ b/core/Controller/RecommendedAppsController.php
@@ -51,5 +51,4 @@ class RecommendedAppsController extends Controller {
$this->initialStateService->provideInitialState('core', 'defaultPageUrl', \OC_Util::getDefaultPageUrl());
return new StandaloneTemplateResponse($this->appName, 'recommendedapps', [], 'guest');
}
-
}
diff --git a/core/Controller/SetupController.php b/core/Controller/SetupController.php
index d77f6982f3d..b57b991884c 100644
--- a/core/Controller/SetupController.php
+++ b/core/Controller/SetupController.php
@@ -70,12 +70,12 @@ class SetupController {
return;
}
- if(isset($post['install']) and $post['install']=='true') {
+ if (isset($post['install']) and $post['install']=='true') {
// We have to launch the installation process :
$e = $this->setupHelper->install($post);
$errors = ['errors' => $e];
- if(count($e) > 0) {
+ if (count($e) > 0) {
$options = array_merge($opts, $post, $errors);
$this->display($options);
} else {
@@ -109,7 +109,7 @@ class SetupController {
}
private function finishSetup(bool $installRecommended) {
- if(file_exists($this->autoConfigFile)) {
+ if (file_exists($this->autoConfigFile)) {
unlink($this->autoConfigFile);
}
\OC::$server->getIntegrityCodeChecker()->runInstanceVerification();
@@ -130,7 +130,7 @@ class SetupController {
}
public function loadAutoConfig($post) {
- if(file_exists($this->autoConfigFile)) {
+ if (file_exists($this->autoConfigFile)) {
\OCP\Util::writeLog('core', 'Autoconfig file found, setting up Nextcloud…', ILogger::INFO);
$AUTOCONFIG = [];
include $this->autoConfigFile;
diff --git a/core/Controller/TwoFactorChallengeController.php b/core/Controller/TwoFactorChallengeController.php
index 4209e48e648..251ae85b3f7 100644
--- a/core/Controller/TwoFactorChallengeController.php
+++ b/core/Controller/TwoFactorChallengeController.php
@@ -278,5 +278,4 @@ class TwoFactorChallengeController extends Controller {
]
));
}
-
}
diff --git a/core/Controller/UserController.php b/core/Controller/UserController.php
index 2b78ba1aaea..638e4e00e46 100644
--- a/core/Controller/UserController.php
+++ b/core/Controller/UserController.php
@@ -71,6 +71,5 @@ class UserController extends Controller {
];
return new JSONResponse($json);
-
}
}
diff --git a/core/Controller/WebAuthnController.php b/core/Controller/WebAuthnController.php
index 1d667311ff7..7315053f12d 100644
--- a/core/Controller/WebAuthnController.php
+++ b/core/Controller/WebAuthnController.php
@@ -38,7 +38,6 @@ use OCP\Util;
use Webauthn\PublicKeyCredentialRequestOptions;
class WebAuthnController extends Controller {
-
private const WEBAUTHN_LOGIN = 'webauthn_login';
private const WEBAUTHN_LOGIN_UID = 'webauthn_login_uid';
diff --git a/core/Controller/WhatsNewController.php b/core/Controller/WhatsNewController.php
index 159e88e1474..3a72486b26a 100644
--- a/core/Controller/WhatsNewController.php
+++ b/core/Controller/WhatsNewController.php
@@ -74,13 +74,13 @@ class WhatsNewController extends OCSController {
*/
public function get():DataResponse {
$user = $this->userSession->getUser();
- if($user === null) {
+ if ($user === null) {
throw new \RuntimeException("Acting user cannot be resolved");
}
$lastRead = $this->config->getUserValue($user->getUID(), 'core', 'whatsNewLastRead', 0);
$currentVersion = $this->whatsNewService->normalizeVersion($this->config->getSystemValue('version'));
- if(version_compare($lastRead, $currentVersion, '>=')) {
+ if (version_compare($lastRead, $currentVersion, '>=')) {
return new DataResponse([], Http::STATUS_NO_CONTENT);
}
@@ -94,7 +94,7 @@ class WhatsNewController extends OCSController {
];
do {
$lang = $iterator->current();
- if(isset($whatsNew['whatsNew'][$lang])) {
+ if (isset($whatsNew['whatsNew'][$lang])) {
$resultData['whatsNew'] = $whatsNew['whatsNew'][$lang];
break;
}
@@ -114,7 +114,7 @@ class WhatsNewController extends OCSController {
*/
public function dismiss(string $version):DataResponse {
$user = $this->userSession->getUser();
- if($user === null) {
+ if ($user === null) {
throw new \RuntimeException("Acting user cannot be resolved");
}
$version = $this->whatsNewService->normalizeVersion($version);
diff --git a/core/Controller/WipeController.php b/core/Controller/WipeController.php
index 378fb112850..bc3cc7ba063 100644
--- a/core/Controller/WipeController.php
+++ b/core/Controller/WipeController.php
@@ -94,5 +94,4 @@ class WipeController extends Controller {
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
}
-
}