diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
commit | caff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch) | |
tree | 186d494c2aea5dea7255d3584ef5d595fc6e6194 /apps/settings/lib | |
parent | edf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff) | |
download | nextcloud-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 'apps/settings/lib')
27 files changed, 72 insertions, 112 deletions
diff --git a/apps/settings/lib/Activity/GroupProvider.php b/apps/settings/lib/Activity/GroupProvider.php index 65ca2627775..ab34e907ca3 100644 --- a/apps/settings/lib/Activity/GroupProvider.php +++ b/apps/settings/lib/Activity/GroupProvider.php @@ -36,7 +36,6 @@ use OCP\IUserManager; use OCP\L10N\IFactory as L10nFactory; class GroupProvider implements IProvider { - public const ADDED_TO_GROUP = 'group_added'; public const REMOVED_FROM_GROUP = 'group_removed'; diff --git a/apps/settings/lib/Activity/Provider.php b/apps/settings/lib/Activity/Provider.php index ecf653eb0e4..5023b4af199 100644 --- a/apps/settings/lib/Activity/Provider.php +++ b/apps/settings/lib/Activity/Provider.php @@ -38,7 +38,6 @@ use OCP\IUserManager; use OCP\L10N\IFactory; class Provider implements IProvider { - public const PASSWORD_CHANGED_BY = 'password_changed_by'; public const PASSWORD_CHANGED_SELF = 'password_changed_self'; public const PASSWORD_RESET = 'password_changed'; @@ -106,14 +105,12 @@ class Provider implements IProvider { $subject = $this->l->t('You changed your password'); } elseif ($event->getSubject() === self::PASSWORD_RESET) { $subject = $this->l->t('Your password was reset by an administrator'); - } elseif ($event->getSubject() === self::EMAIL_CHANGED_BY) { $subject = $this->l->t('{actor} changed your email address'); } elseif ($event->getSubject() === self::EMAIL_CHANGED_SELF) { $subject = $this->l->t('You changed your email address'); } elseif ($event->getSubject() === self::EMAIL_CHANGED) { $subject = $this->l->t('Your email address was changed by an administrator'); - } elseif ($event->getSubject() === self::APP_TOKEN_CREATED) { $subject = $this->l->t('You created app password "{token}"'); } elseif ($event->getSubject() === self::APP_TOKEN_DELETED) { @@ -124,7 +121,6 @@ class Provider implements IProvider { $subject = $this->l->t('You granted filesystem access to app password "{token}"'); } elseif ($event->getSubject() === self::APP_TOKEN_FILESYSTEM_REVOKED) { $subject = $this->l->t('You revoked filesystem access from app password "{token}"'); - } else { throw new \InvalidArgumentException('Unknown subject'); } diff --git a/apps/settings/lib/Activity/SecurityFilter.php b/apps/settings/lib/Activity/SecurityFilter.php index dd0312232fe..d814571897c 100644 --- a/apps/settings/lib/Activity/SecurityFilter.php +++ b/apps/settings/lib/Activity/SecurityFilter.php @@ -63,5 +63,4 @@ class SecurityFilter implements IFilter { public function getPriority() { return 30; } - } diff --git a/apps/settings/lib/Activity/SecurityProvider.php b/apps/settings/lib/Activity/SecurityProvider.php index 568006d03cc..20156bbc407 100644 --- a/apps/settings/lib/Activity/SecurityProvider.php +++ b/apps/settings/lib/Activity/SecurityProvider.php @@ -109,5 +109,4 @@ class SecurityProvider implements IProvider { } return $event; } - } diff --git a/apps/settings/lib/Activity/SecuritySetting.php b/apps/settings/lib/Activity/SecuritySetting.php index d276285d484..c9ed42b2e2a 100644 --- a/apps/settings/lib/Activity/SecuritySetting.php +++ b/apps/settings/lib/Activity/SecuritySetting.php @@ -62,5 +62,4 @@ class SecuritySetting implements ISetting { public function isDefaultEnabledStream() { return true; } - } diff --git a/apps/settings/lib/AppInfo/Application.php b/apps/settings/lib/AppInfo/Application.php index f53a5ddcf51..809fe6cf844 100644 --- a/apps/settings/lib/AppInfo/Application.php +++ b/apps/settings/lib/AppInfo/Application.php @@ -54,7 +54,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; class Application extends App { - const APP_ID = 'settings'; /** @@ -80,7 +79,7 @@ class Application extends App { $container->registerService('isSubAdmin', function (IContainer $c) { $userObject = \OC::$server->getUserSession()->getUser(); $isSubAdmin = false; - if($userObject !== null) { + if ($userObject !== null) { $isSubAdmin = \OC::$server->getGroupManager()->getSubAdmin()->isSubAdmin($userObject); } return $isSubAdmin; @@ -158,7 +157,6 @@ class Application extends App { /** @var Hooks $hooks */ $hooks = $this->getContainer()->query(Hooks::class); $hooks->addUserToGroup($group, $user); - } public function removeUserFromGroup(IGroup $group, IUser $user): void { diff --git a/apps/settings/lib/BackgroundJobs/VerifyUserData.php b/apps/settings/lib/BackgroundJobs/VerifyUserData.php index a5c46c603bf..e77d95ff4d9 100644 --- a/apps/settings/lib/BackgroundJobs/VerifyUserData.php +++ b/apps/settings/lib/BackgroundJobs/VerifyUserData.php @@ -100,7 +100,6 @@ class VerifyUserData extends Job { * @param ILogger|null $logger */ public function execute($jobList, ILogger $logger = null) { - if ($this->shouldRun($this->argument)) { parent::execute($jobList, $logger); $jobList->remove($this, $this->argument); @@ -110,14 +109,12 @@ class VerifyUserData extends Job { $this->resetVerificationState(); } } - } protected function run($argument) { - $try = (int)$argument['try'] + 1; - switch($argument['type']) { + switch ($argument['type']) { case AccountManager::PROPERTY_WEBSITE: $result = $this->verifyWebsite($argument); break; @@ -143,7 +140,6 @@ class VerifyUserData extends Job { * @return bool true if we could check the verification code, otherwise false */ protected function verifyWebsite(array $argument) { - $result = false; $url = rtrim($argument['data'], '/') . '/.well-known/' . 'CloudIdVerificationCode.txt'; @@ -188,7 +184,7 @@ class VerifyUserData extends Job { * @return bool true if we could check the verification code, otherwise false */ protected function verifyViaLookupServer(array $argument, $dataType) { - if(empty($this->lookupServerUrl) || + if (empty($this->lookupServerUrl) || $this->config->getAppValue('files_sharing', 'lookupServerUploadEnabled', 'yes') !== 'yes' || $this->config->getSystemValue('has_internet_connection', true) === false) { return false; @@ -249,7 +245,6 @@ class VerifyUserData extends Job { if (is_array($body) && isset($body['federationId']) && $body['federationId'] === $cloudId) { return $body; } - } catch (\Exception $e) { // do nothing, we will just re-try later } @@ -299,5 +294,4 @@ class VerifyUserData extends Job { $this->accountManager->updateUser($user, $accountData); } } - } diff --git a/apps/settings/lib/Controller/AdminSettingsController.php b/apps/settings/lib/Controller/AdminSettingsController.php index e7b1a27a637..c50ffc6f1e7 100644 --- a/apps/settings/lib/Controller/AdminSettingsController.php +++ b/apps/settings/lib/Controller/AdminSettingsController.php @@ -82,7 +82,7 @@ class AdminSettingsController extends Controller { ); $formatted = $this->formatSettings($settings); // Do not show legacy forms for sub admins - if($section === 'additional' && !$isSubAdmin) { + if ($section === 'additional' && !$isSubAdmin) { $formatted['content'] .= $this->getLegacyForms(); } return $formatted; @@ -117,6 +117,4 @@ class AdminSettingsController extends Controller { return $out->fetchPage(); } - - } diff --git a/apps/settings/lib/Controller/AppSettingsController.php b/apps/settings/lib/Controller/AppSettingsController.php index f40a8024b6d..7dbbaca1a45 100644 --- a/apps/settings/lib/Controller/AppSettingsController.php +++ b/apps/settings/lib/Controller/AppSettingsController.php @@ -149,9 +149,9 @@ class AppSettingsController extends Controller { private function getAppsWithUpdates() { $appClass = new \OC_App(); $apps = $appClass->listAllApps(); - foreach($apps as $key => $app) { + foreach ($apps as $key => $app) { $newVersion = $this->installer->isUpdateAvailable($app['id']); - if($newVersion === false) { + if ($newVersion === false) { unset($apps[$key]); } } @@ -169,7 +169,6 @@ class AppSettingsController extends Controller { ]; } return $result; - } /** @@ -186,7 +185,7 @@ class AppSettingsController extends Controller { $formattedCategories = []; $categories = $this->categoryFetcher->get(); - foreach($categories as $category) { + foreach ($categories as $category) { $formattedCategories[] = [ 'id' => $category['id'], 'ident' => $category['id'], @@ -217,10 +216,10 @@ class AppSettingsController extends Controller { // add bundle information $bundles = $this->bundleFetcher->getBundles(); - foreach($bundles as $bundle) { - foreach($bundle->getAppIdentifiers() as $identifier) { - foreach($this->allApps as &$app) { - if($app['id'] === $identifier) { + foreach ($bundles as $bundle) { + foreach ($bundle->getAppIdentifiers() as $identifier) { + foreach ($this->allApps as &$app) { + if ($app['id'] === $identifier) { $app['bundleIds'][] = $bundle->getIdentifier(); continue; } @@ -240,7 +239,6 @@ class AppSettingsController extends Controller { * @throws \Exception */ public function listApps(): JSONResponse { - $this->fetchApps(); $apps = $this->getAllApps(); @@ -255,7 +253,7 @@ class AppSettingsController extends Controller { } $newVersion = $this->installer->isUpdateAvailable($appData['id']); - if($newVersion) { + if ($newVersion) { $appData['update'] = $newVersion; } @@ -307,16 +305,16 @@ class AppSettingsController extends Controller { $versionParser = new VersionParser(); $formattedApps = []; $apps = $this->appFetcher->get(); - foreach($apps as $app) { + foreach ($apps as $app) { // Skip all apps not in the requested category if ($requestedCategory !== '') { $isInCategory = false; - foreach($app['categories'] as $category) { - if($category === $requestedCategory) { + foreach ($app['categories'] as $category) { + if ($category === $requestedCategory) { $isInCategory = true; } } - if(!$isInCategory) { + if (!$isInCategory) { continue; } } @@ -326,28 +324,28 @@ class AppSettingsController extends Controller { } $nextCloudVersion = $versionParser->getVersion($app['releases'][0]['rawPlatformVersionSpec']); $nextCloudVersionDependencies = []; - if($nextCloudVersion->getMinimumVersion() !== '') { + if ($nextCloudVersion->getMinimumVersion() !== '') { $nextCloudVersionDependencies['nextcloud']['@attributes']['min-version'] = $nextCloudVersion->getMinimumVersion(); } - if($nextCloudVersion->getMaximumVersion() !== '') { + if ($nextCloudVersion->getMaximumVersion() !== '') { $nextCloudVersionDependencies['nextcloud']['@attributes']['max-version'] = $nextCloudVersion->getMaximumVersion(); } $phpVersion = $versionParser->getVersion($app['releases'][0]['rawPhpVersionSpec']); $existsLocally = \OC_App::getAppPath($app['id']) !== false; $phpDependencies = []; - if($phpVersion->getMinimumVersion() !== '') { + if ($phpVersion->getMinimumVersion() !== '') { $phpDependencies['php']['@attributes']['min-version'] = $phpVersion->getMinimumVersion(); } - if($phpVersion->getMaximumVersion() !== '') { + if ($phpVersion->getMaximumVersion() !== '') { $phpDependencies['php']['@attributes']['max-version'] = $phpVersion->getMaximumVersion(); } - if(isset($app['releases'][0]['minIntSize'])) { + if (isset($app['releases'][0]['minIntSize'])) { $phpDependencies['php']['@attributes']['min-int-size'] = $app['releases'][0]['minIntSize']; } $authors = ''; - foreach($app['authors'] as $key => $author) { + foreach ($app['authors'] as $key => $author) { $authors .= $author['name']; - if($key !== count($app['authors']) - 1) { + if ($key !== count($app['authors']) - 1) { $authors .= ', '; } } @@ -355,12 +353,12 @@ class AppSettingsController extends Controller { $currentLanguage = substr(\OC::$server->getL10NFactory()->findLanguage(), 0, 2); $enabledValue = $this->config->getAppValue($app['id'], 'enabled', 'no'); $groups = null; - if($enabledValue !== 'no' && $enabledValue !== 'yes') { + if ($enabledValue !== 'no' && $enabledValue !== 'yes') { $groups = $enabledValue; } $currentVersion = ''; - if($this->appManager->isInstalled($app['id'])) { + if ($this->appManager->isInstalled($app['id'])) { $currentVersion = $this->appManager->getAppVersion($app['id']); } else { $currentLanguage = $app['releases'][0]['version']; @@ -442,7 +440,7 @@ class AppSettingsController extends Controller { $installer = \OC::$server->query(Installer::class); $isDownloaded = $installer->isDownloaded($appId); - if(!$isDownloaded) { + if (!$isDownloaded) { $installer->downloadApp($appId); } @@ -458,7 +456,6 @@ class AppSettingsController extends Controller { } } return new JSONResponse(['data' => ['update_required' => $updateRequired]]); - } catch (\Exception $e) { $this->logger->logException($e); return new JSONResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_INTERNAL_SERVER_ERROR); @@ -515,7 +512,7 @@ class AppSettingsController extends Controller { public function uninstallApp(string $appId): JSONResponse { $appId = OC_App::cleanAppId($appId); $result = $this->installer->removeApp($appId); - if($result !== false) { + if ($result !== false) { $this->appManager->clearAppsCache(); return new JSONResponse(['data' => ['appid' => $appId]]); } @@ -558,5 +555,4 @@ class AppSettingsController extends Controller { $this->appManager->ignoreNextcloudRequirementForApp($appId); return new JSONResponse(); } - } diff --git a/apps/settings/lib/Controller/AuthSettingsController.php b/apps/settings/lib/Controller/AuthSettingsController.php index 405044746a3..0296a1ac5cb 100644 --- a/apps/settings/lib/Controller/AuthSettingsController.php +++ b/apps/settings/lib/Controller/AuthSettingsController.php @@ -126,8 +126,7 @@ class AuthSettingsController extends Controller { } catch (SessionNotAvailableException $ex) { return $this->getServiceNotAvailableResponse(); } - if ($this->userSession->getImpersonatingUserID() !== null) - { + if ($this->userSession->getImpersonatingUserID() !== null) { return $this->getServiceNotAvailableResponse(); } diff --git a/apps/settings/lib/Controller/CertificateController.php b/apps/settings/lib/Controller/CertificateController.php index d23821bdf9c..b7ce1749660 100644 --- a/apps/settings/lib/Controller/CertificateController.php +++ b/apps/settings/lib/Controller/CertificateController.php @@ -126,7 +126,6 @@ class CertificateController extends Controller { * @return DataResponse */ public function removePersonalRootCertificate($certificateIdentifier) { - if ($this->isCertificateImportAllowed() === false) { return new DataResponse(['Individual certificate management disabled'], Http::STATUS_FORBIDDEN); } @@ -168,7 +167,6 @@ class CertificateController extends Controller { * @return DataResponse */ public function removeSystemRootCertificate($certificateIdentifier) { - if ($this->isCertificateImportAllowed() === false) { return new DataResponse(['Individual certificate management disabled'], Http::STATUS_FORBIDDEN); } diff --git a/apps/settings/lib/Controller/ChangePasswordController.php b/apps/settings/lib/Controller/ChangePasswordController.php index 20b8357a6a9..439731b22eb 100644 --- a/apps/settings/lib/Controller/ChangePasswordController.php +++ b/apps/settings/lib/Controller/ChangePasswordController.php @@ -108,8 +108,8 @@ class ChangePasswordController extends Controller { 'status' => 'error' ]); } - // password policy app throws exception - } catch(HintException $e) { + // password policy app throws exception + } catch (HintException $e) { return new JSONResponse([ 'status' => 'error', 'data' => [ @@ -221,8 +221,8 @@ class ChangePasswordController extends Controller { } else { // now we know that everything is fine regarding the recovery password, let's try to change the password try { $result = $targetUser->setPassword($password, $recoveryPassword); - // password policy app throws exception - } catch(HintException $e) { + // password policy app throws exception + } catch (HintException $e) { return new JSONResponse([ 'status' => 'error', 'data' => [ @@ -256,8 +256,8 @@ class ChangePasswordController extends Controller { ], ]); } - // password policy app throws exception - } catch(HintException $e) { + // password policy app throws exception + } catch (HintException $e) { return new JSONResponse([ 'status' => 'error', 'data' => [ diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php index e386f29a94e..a0d374e5b44 100644 --- a/apps/settings/lib/Controller/CheckSetupController.php +++ b/apps/settings/lib/Controller/CheckSetupController.php @@ -137,7 +137,7 @@ class CheckSetupController extends Controller { 'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org' ]); - foreach($siteArray as $site) { + foreach ($siteArray as $site) { if ($this->isSiteReachable($site)) { return false; } @@ -208,40 +208,40 @@ class CheckSetupController extends Controller { // Don't run check when: // 1. Server has `has_internet_connection` set to false // 2. AppStore AND S2S is disabled - if(!$this->config->getSystemValue('has_internet_connection', true)) { + if (!$this->config->getSystemValue('has_internet_connection', true)) { return ''; } - if(!$this->config->getSystemValue('appstoreenabled', true) + if (!$this->config->getSystemValue('appstoreenabled', true) && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { return ''; } $versionString = $this->getCurlVersion(); - if(isset($versionString['ssl_version'])) { + if (isset($versionString['ssl_version'])) { $versionString = $versionString['ssl_version']; } else { return ''; } $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); - if(!$this->config->getSystemValue('appstoreenabled', true)) { + if (!$this->config->getSystemValue('appstoreenabled', true)) { $features = (string)$this->l10n->t('Federated Cloud Sharing'); } // Check if at least OpenSSL after 1.01d or 1.0.2b - if(strpos($versionString, 'OpenSSL/') === 0) { + if (strpos($versionString, 'OpenSSL/') === 0) { $majorVersion = substr($versionString, 8, 5); $patchRelease = substr($versionString, 13, 6); - if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || + if (($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['OpenSSL', $versionString, $features]); } } // Check if NSS and perform heuristic check - if(strpos($versionString, 'NSS/') === 0) { + if (strpos($versionString, 'NSS/') === 0) { try { $firstClient = $this->clientService->newClient(); $firstClient->get('https://nextcloud.com/'); @@ -249,7 +249,7 @@ class CheckSetupController extends Controller { $secondClient = $this->clientService->newClient(); $secondClient->get('https://nextcloud.com/'); } catch (ClientException $e) { - if($e->getResponse()->getStatusCode() === 400) { + if ($e->getResponse()->getStatusCode() === 400) { return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['NSS', $versionString, $features]); } } @@ -344,13 +344,13 @@ class CheckSetupController extends Controller { * @return DataResponse */ public function getFailedIntegrityCheckFiles() { - if(!$this->checker->isCodeCheckEnforced()) { + if (!$this->checker->isCodeCheckEnforced()) { return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); } $completeResults = $this->checker->getResults(); - if(!empty($completeResults)) { + if (!empty($completeResults)) { $formattedTextResponse = 'Technical information ===================== The following list covers which files have failed the integrity check. Please read @@ -360,12 +360,12 @@ them. Results ======= '; - foreach($completeResults as $context => $contextResult) { + foreach ($completeResults as $context => $contextResult) { $formattedTextResponse .= "- $context\n"; - foreach($contextResult as $category => $result) { + foreach ($contextResult as $category => $result) { $formattedTextResponse .= "\t- $category\n"; - if($category !== 'EXCEPTION') { + if ($category !== 'EXCEPTION') { foreach ($result as $key => $results) { $formattedTextResponse .= "\t\t- $key\n"; } @@ -374,7 +374,6 @@ Results $formattedTextResponse .= "\t\t- $results\n"; } } - } } @@ -406,23 +405,23 @@ Raw output protected function isOpcacheProperlySetup() { $iniWrapper = new IniGetWrapper(); - if(!$iniWrapper->getBool('opcache.enable')) { + if (!$iniWrapper->getBool('opcache.enable')) { return false; } - if(!$iniWrapper->getBool('opcache.save_comments')) { + if (!$iniWrapper->getBool('opcache.save_comments')) { return false; } - if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { + if ($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { return false; } - if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { + if ($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { return false; } - if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { + if ($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { return false; } diff --git a/apps/settings/lib/Controller/CommonSettingsTrait.php b/apps/settings/lib/Controller/CommonSettingsTrait.php index 7aa202429eb..f5c8bb465fd 100644 --- a/apps/settings/lib/Controller/CommonSettingsTrait.php +++ b/apps/settings/lib/Controller/CommonSettingsTrait.php @@ -38,7 +38,7 @@ use OCP\Settings\IIconSection; use OCP\Settings\IManager as ISettingsManager; use OCP\Settings\ISettings; -trait CommonSettingsTrait { +trait CommonSettingsTrait { /** @var ISettingsManager */ private $settingsManager; @@ -85,11 +85,11 @@ trait CommonSettingsTrait { protected function formatSections($sections, $currentSection, $type, $currentType, bool $subAdminOnly = false) { $templateParameters = []; /** @var \OCP\Settings\ISection[] $prioritizedSections */ - foreach($sections as $prioritizedSections) { + foreach ($sections as $prioritizedSections) { foreach ($prioritizedSections as $section) { - if($type === 'admin') { + if ($type === 'admin') { $settings = $this->settingsManager->getAdminSettings($section->getID(), $subAdminOnly); - } elseif($type === 'personal') { + } elseif ($type === 'personal') { $settings = $this->settingsManager->getPersonalSettings($section->getID()); } if (empty($settings) && !($section->getID() === 'additional' && count(\OC_App::getForms('admin')) > 0)) { diff --git a/apps/settings/lib/Controller/HelpController.php b/apps/settings/lib/Controller/HelpController.php index cf470d6af4b..58fb18ea2c5 100644 --- a/apps/settings/lib/Controller/HelpController.php +++ b/apps/settings/lib/Controller/HelpController.php @@ -71,7 +71,7 @@ class HelpController extends Controller { public function help(string $mode = 'user'): TemplateResponse { $this->navigationManager->setActiveEntry('help'); - if(!isset($mode) || $mode !== 'admin') { + if (!isset($mode) || $mode !== 'admin') { $mode = 'user'; } @@ -93,7 +93,5 @@ class HelpController extends Controller { $policy->addAllowedFrameDomain('\'self\''); $response->setContentSecurityPolicy($policy); return $response; - } - } diff --git a/apps/settings/lib/Controller/LogSettingsController.php b/apps/settings/lib/Controller/LogSettingsController.php index 648b0ff1c3b..31abc144371 100644 --- a/apps/settings/lib/Controller/LogSettingsController.php +++ b/apps/settings/lib/Controller/LogSettingsController.php @@ -51,7 +51,7 @@ class LogSettingsController extends Controller { * @return StreamResponse */ public function download() { - if(!$this->log instanceof Log) { + if (!$this->log instanceof Log) { throw new \UnexpectedValueException('Log file not available'); } $resp = new StreamResponse($this->log->getLogPath()); diff --git a/apps/settings/lib/Controller/MailSettingsController.php b/apps/settings/lib/Controller/MailSettingsController.php index 5dc0ff9d890..94f9d72cafd 100644 --- a/apps/settings/lib/Controller/MailSettingsController.php +++ b/apps/settings/lib/Controller/MailSettingsController.php @@ -93,10 +93,9 @@ class MailSettingsController extends Controller { $mail_smtpauth, $mail_smtpport, $mail_sendmailmode) { - $params = get_defined_vars(); $configs = []; - foreach($params as $key => $value) { + foreach ($params as $key => $value) { $configs[$key] = empty($value) ? null : $value; } @@ -168,5 +167,4 @@ class MailSettingsController extends Controller { return new DataResponse($this->l10n->t('You need to set your user email before being able to send test emails.'), Http::STATUS_BAD_REQUEST); } - } diff --git a/apps/settings/lib/Controller/PersonalSettingsController.php b/apps/settings/lib/Controller/PersonalSettingsController.php index 12d8af3af17..0aff8bee649 100644 --- a/apps/settings/lib/Controller/PersonalSettingsController.php +++ b/apps/settings/lib/Controller/PersonalSettingsController.php @@ -65,7 +65,6 @@ class PersonalSettingsController extends Controller { */ public function index($section) { return $this->getIndexResponse('personal', $section); - } /** @@ -75,7 +74,7 @@ class PersonalSettingsController extends Controller { protected function getSettings($section) { $settings = $this->settingsManager->getPersonalSettings($section); $formatted = $this->formatSettings($settings); - if($section === 'additional') { + if ($section === 'additional') { $formatted['content'] .= $this->getLegacyForms(); } return $formatted; diff --git a/apps/settings/lib/Controller/TwoFactorSettingsController.php b/apps/settings/lib/Controller/TwoFactorSettingsController.php index 77d8e882354..36b554c8181 100644 --- a/apps/settings/lib/Controller/TwoFactorSettingsController.php +++ b/apps/settings/lib/Controller/TwoFactorSettingsController.php @@ -56,5 +56,4 @@ class TwoFactorSettingsController extends Controller { return new JSONResponse($this->mandatoryTwoFactor->getState()); } - } diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index 5a4ebd122f8..abc4715df6c 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -172,7 +172,7 @@ class UsersController extends Controller { $groupsInfo->setSorting($sortGroupsBy); list($adminGroup, $groups) = $groupsInfo->get(); - if(!$isLDAPUsed && $this->appManager->isEnabledForUser('user_ldap')) { + if (!$isLDAPUsed && $this->appManager->isEnabledForUser('user_ldap')) { $isLDAPUsed = (bool)array_reduce($this->userManager->getBackends(), function ($ldapFound, $backend) { return $ldapFound || $backend instanceof User_Proxy; }); @@ -181,7 +181,7 @@ class UsersController extends Controller { $disabledUsers = -1; $userCount = 0; - if(!$isLDAPUsed) { + if (!$isLDAPUsed) { if ($this->isAdmin) { $disabledUsers = $this->userManager->countDisabledUsers(); $userCount = array_reduce($this->userManager->countUsers(), function ($v, $w) { @@ -193,7 +193,7 @@ class UsersController extends Controller { $userGroups = $this->groupManager->getUserGroups($user); $groupsNames = []; - foreach($groups as $key => $group) { + foreach ($groups as $key => $group) { // $userCount += (int)$group['usercount']; array_push($groupsNames, $group['name']); // we prevent subadmins from looking up themselves @@ -447,7 +447,6 @@ class UsersController extends Controller { * @return DataResponse */ public function getVerificationCode(string $account, bool $onlyVerificationCode): DataResponse { - $user = $this->userSession->getUser(); if ($user === null) { diff --git a/apps/settings/lib/Controller/WebAuthnController.php b/apps/settings/lib/Controller/WebAuthnController.php index cbc396b675f..c1ce7a6cf98 100644 --- a/apps/settings/lib/Controller/WebAuthnController.php +++ b/apps/settings/lib/Controller/WebAuthnController.php @@ -37,7 +37,6 @@ use OCP\IUserSession; use Webauthn\PublicKeyCredentialCreationOptions; class WebAuthnController extends Controller { - private const WEBAUTHN_REGISTRATION = 'webauthn_registration'; /** @var Manager */ diff --git a/apps/settings/lib/Hooks.php b/apps/settings/lib/Hooks.php index baa8941bd32..851f2f143dc 100644 --- a/apps/settings/lib/Hooks.php +++ b/apps/settings/lib/Hooks.php @@ -157,7 +157,6 @@ class Hooks { * @throws \BadMethodCallException */ public function onChangeEmail(IUser $user, $oldMailAddress) { - if ($oldMailAddress === $user->getEMailAddress() || $user->getLastLogin() === 0) { // Email didn't really change or user didn't login, diff --git a/apps/settings/lib/Mailer/NewUserMailHelper.php b/apps/settings/lib/Mailer/NewUserMailHelper.php index ca6a5947527..75b1593c6b1 100644 --- a/apps/settings/lib/Mailer/NewUserMailHelper.php +++ b/apps/settings/lib/Mailer/NewUserMailHelper.php @@ -139,7 +139,7 @@ class NewUserMailHelper { $emailTemplate->addHeading($l10n->t('Welcome aboard %s', [$displayName])); } $emailTemplate->addBodyText($l10n->t('Welcome to your %s account, you can add, protect, and share your data.', [$this->themingDefaults->getName()])); - if($user->getBackendClassName() !== 'LDAP') { + if ($user->getBackendClassName() !== 'LDAP') { $emailTemplate->addBodyText($l10n->t('Your username is: %s', [$userId])); } if ($generatePasswordResetToken) { diff --git a/apps/settings/lib/Middleware/SubadminMiddleware.php b/apps/settings/lib/Middleware/SubadminMiddleware.php index ffc507e50e0..7fa30c8e26c 100644 --- a/apps/settings/lib/Middleware/SubadminMiddleware.php +++ b/apps/settings/lib/Middleware/SubadminMiddleware.php @@ -65,8 +65,8 @@ class SubadminMiddleware extends Middleware { * @throws \Exception */ public function beforeController($controller, $methodName) { - if(!$this->reflector->hasAnnotation('NoSubadminRequired')) { - if(!$this->isSubAdmin) { + if (!$this->reflector->hasAnnotation('NoSubadminRequired')) { + if (!$this->isSubAdmin) { throw new NotAdminException($this->l10n->t('Logged in user must be a subadmin')); } } @@ -81,7 +81,7 @@ class SubadminMiddleware extends Middleware { * @throws \Exception */ public function afterException($controller, $methodName, \Exception $exception) { - if($exception instanceof NotAdminException) { + if ($exception instanceof NotAdminException) { $response = new TemplateResponse('core', '403', [], 'guest'); $response->setStatus(Http::STATUS_FORBIDDEN); return $response; @@ -89,5 +89,4 @@ class SubadminMiddleware extends Middleware { throw $exception; } - } diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php index e6bc4388359..152259b743f 100644 --- a/apps/settings/lib/Settings/Personal/PersonalInfo.php +++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php @@ -95,7 +95,7 @@ class PersonalInfo implements ISettings { public function getForm() { $federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing'); $lookupServerUploadEnabled = false; - if($federatedFileSharingEnabled) { + if ($federatedFileSharingEnabled) { $federatedFileSharing = \OC::$server->query(Application::class); $shareProvider = $federatedFileSharing->getFederatedShareProvider(); $lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled(); @@ -194,7 +194,7 @@ class PersonalInfo implements ISettings { */ private function getLanguages(IUser $user) { $forceLanguage = $this->config->getSystemValue('force_language', false); - if($forceLanguage !== false) { + if ($forceLanguage !== false) { return []; } @@ -227,7 +227,7 @@ class PersonalInfo implements ISettings { private function getLocales(IUser $user) { $forceLanguage = $this->config->getSystemValue('force_locale', false); - if($forceLanguage !== false) { + if ($forceLanguage !== false) { return []; } @@ -243,8 +243,7 @@ class PersonalInfo implements ISettings { return $userLocaleString === $value['code']; }); - if (!empty($userLocale)) - { + if (!empty($userLocale)) { $userLocale = reset($userLocale); } @@ -289,5 +288,4 @@ class PersonalInfo implements ISettings { } return $messageParameters; } - } diff --git a/apps/settings/lib/Settings/Personal/Security/Authtokens.php b/apps/settings/lib/Settings/Personal/Security/Authtokens.php index 3e33723a62b..22aca1660d9 100644 --- a/apps/settings/lib/Settings/Personal/Security/Authtokens.php +++ b/apps/settings/lib/Settings/Personal/Security/Authtokens.php @@ -117,5 +117,4 @@ class Authtokens implements ISettings { return $data; }, $tokens); } - } diff --git a/apps/settings/lib/Settings/Personal/Security/TwoFactor.php b/apps/settings/lib/Settings/Personal/Security/TwoFactor.php index 4db8f6f8ab2..ca20274b33d 100644 --- a/apps/settings/lib/Settings/Personal/Security/TwoFactor.php +++ b/apps/settings/lib/Settings/Personal/Security/TwoFactor.php @@ -66,7 +66,6 @@ class TwoFactor implements ISettings { 'twoFactorProviderData' => $this->getTwoFactorProviderData(), 'themedark' => $this->config->getUserValue($this->uid, 'accessibility', 'theme', false) ]); - } public function getSection(): string { |