aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/Command
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 /apps/user_ldap/lib/Command
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 'apps/user_ldap/lib/Command')
-rw-r--r--apps/user_ldap/lib/Command/CheckUser.php7
-rw-r--r--apps/user_ldap/lib/Command/CreateEmptyConfig.php2
-rw-r--r--apps/user_ldap/lib/Command/DeleteConfig.php2
-rw-r--r--apps/user_ldap/lib/Command/Search.php12
-rw-r--r--apps/user_ldap/lib/Command/SetConfig.php3
-rw-r--r--apps/user_ldap/lib/Command/ShowConfig.php12
-rw-r--r--apps/user_ldap/lib/Command/TestConfig.php13
7 files changed, 24 insertions, 27 deletions
diff --git a/apps/user_ldap/lib/Command/CheckUser.php b/apps/user_ldap/lib/Command/CheckUser.php
index 5b837e47b8e..430e9c35960 100644
--- a/apps/user_ldap/lib/Command/CheckUser.php
+++ b/apps/user_ldap/lib/Command/CheckUser.php
@@ -92,9 +92,9 @@ class CheckUser extends Command {
$this->isAllowed($input->getOption('force'));
$this->confirmUserIsMapped($uid);
$exists = $this->backend->userExistsOnLDAP($uid);
- if($exists === true) {
+ if ($exists === true) {
$output->writeln('The user is still available on LDAP.');
- if($input->getOption('update')) {
+ if ($input->getOption('update')) {
$this->updateUser($uid, $output);
}
return;
@@ -130,7 +130,7 @@ class CheckUser extends Command {
* @return true
*/
protected function isAllowed($force) {
- if($this->helper->haveDisabledConfigurations() && !$force) {
+ if ($this->helper->haveDisabledConfigurations() && !$force) {
throw new \Exception('Cannot check user existence, because '
. 'disabled LDAP configurations are present.');
}
@@ -163,5 +163,4 @@ class CheckUser extends Command {
$output->writeln('<error>Error while trying to lookup and update attributes from LDAP</error>');
}
}
-
}
diff --git a/apps/user_ldap/lib/Command/CreateEmptyConfig.php b/apps/user_ldap/lib/Command/CreateEmptyConfig.php
index fab9c513141..8b2b19a5175 100644
--- a/apps/user_ldap/lib/Command/CreateEmptyConfig.php
+++ b/apps/user_ldap/lib/Command/CreateEmptyConfig.php
@@ -63,7 +63,7 @@ class CreateEmptyConfig extends Command {
$configHolder->saveConfiguration();
$prose = '';
- if(!$input->getOption('only-print-prefix')) {
+ if (!$input->getOption('only-print-prefix')) {
$prose = 'Created new configuration with configID ';
}
$output->writeln($prose . "{$configPrefix}");
diff --git a/apps/user_ldap/lib/Command/DeleteConfig.php b/apps/user_ldap/lib/Command/DeleteConfig.php
index f62caf2902a..fd075ae70c3 100644
--- a/apps/user_ldap/lib/Command/DeleteConfig.php
+++ b/apps/user_ldap/lib/Command/DeleteConfig.php
@@ -61,7 +61,7 @@ class DeleteConfig extends Command {
$success = $this->helper->deleteServerConfiguration($configPrefix);
- if($success) {
+ if ($success) {
$output->writeln("Deleted configuration with configID '{$configPrefix}'");
} else {
$output->writeln("Cannot delete configuration with configID '{$configPrefix}'");
diff --git a/apps/user_ldap/lib/Command/Search.php b/apps/user_ldap/lib/Command/Search.php
index edd4fa71ba0..3c05d6cc2ee 100644
--- a/apps/user_ldap/lib/Command/Search.php
+++ b/apps/user_ldap/lib/Command/Search.php
@@ -90,16 +90,16 @@ class Search extends Command {
* @throws \InvalidArgumentException
*/
protected function validateOffsetAndLimit($offset, $limit) {
- if($limit < 0) {
+ if ($limit < 0) {
throw new \InvalidArgumentException('limit must be 0 or greater');
}
- if($offset < 0) {
+ if ($offset < 0) {
throw new \InvalidArgumentException('offset must be 0 or greater');
}
- if($limit === 0 && $offset !== 0) {
+ if ($limit === 0 && $offset !== 0) {
throw new \InvalidArgumentException('offset must be 0 if limit is also set to 0');
}
- if($offset > 0 && ($offset % $limit !== 0)) {
+ if ($offset > 0 && ($offset % $limit !== 0)) {
throw new \InvalidArgumentException('offset must be a multiple of limit');
}
}
@@ -113,7 +113,7 @@ class Search extends Command {
$limit = (int)$input->getOption('limit');
$this->validateOffsetAndLimit($offset, $limit);
- if($input->getOption('group')) {
+ if ($input->getOption('group')) {
$proxy = new Group_Proxy($configPrefixes, $ldapWrapper, \OC::$server->query('LDAPGroupPluginManager'));
$getMethod = 'getGroups';
$printID = false;
@@ -136,7 +136,7 @@ class Search extends Command {
}
$result = $proxy->$getMethod($input->getArgument('search'), $limit, $offset);
- foreach($result as $id => $name) {
+ foreach ($result as $id => $name) {
$line = $name . ($printID ? ' ('.$id.')' : '');
$output->writeln($line);
}
diff --git a/apps/user_ldap/lib/Command/SetConfig.php b/apps/user_ldap/lib/Command/SetConfig.php
index a1ddf3a591a..4c8c47b6411 100644
--- a/apps/user_ldap/lib/Command/SetConfig.php
+++ b/apps/user_ldap/lib/Command/SetConfig.php
@@ -36,7 +36,6 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class SetConfig extends Command {
-
protected function configure() {
$this
->setName('ldap:set-config')
@@ -63,7 +62,7 @@ class SetConfig extends Command {
$helper = new Helper(\OC::$server->getConfig());
$availableConfigs = $helper->getServerConfigurationPrefixes();
$configID = $input->getArgument('configID');
- if(!in_array($configID, $availableConfigs)) {
+ if (!in_array($configID, $availableConfigs)) {
$output->writeln("Invalid configID");
return;
}
diff --git a/apps/user_ldap/lib/Command/ShowConfig.php b/apps/user_ldap/lib/Command/ShowConfig.php
index f4af798d433..cbd94287f9b 100644
--- a/apps/user_ldap/lib/Command/ShowConfig.php
+++ b/apps/user_ldap/lib/Command/ShowConfig.php
@@ -69,9 +69,9 @@ class ShowConfig extends Command {
protected function execute(InputInterface $input, OutputInterface $output) {
$availableConfigs = $this->helper->getServerConfigurationPrefixes();
$configID = $input->getArgument('configID');
- if(!is_null($configID)) {
+ if (!is_null($configID)) {
$configIDs[] = $configID;
- if(!in_array($configIDs[0], $availableConfigs)) {
+ if (!in_array($configIDs[0], $availableConfigs)) {
$output->writeln("Invalid configID");
return;
}
@@ -89,7 +89,7 @@ class ShowConfig extends Command {
* @param bool $withPassword Set to TRUE to show plaintext passwords in output
*/
protected function renderConfigs($configIDs, $output, $withPassword) {
- foreach($configIDs as $id) {
+ foreach ($configIDs as $id) {
$configHolder = new Configuration($id);
$configuration = $configHolder->getConfiguration();
ksort($configuration);
@@ -97,11 +97,11 @@ class ShowConfig extends Command {
$table = new Table($output);
$table->setHeaders(['Configuration', $id]);
$rows = [];
- foreach($configuration as $key => $value) {
- if($key === 'ldapAgentPassword' && !$withPassword) {
+ foreach ($configuration as $key => $value) {
+ if ($key === 'ldapAgentPassword' && !$withPassword) {
$value = '***';
}
- if(is_array($value)) {
+ if (is_array($value)) {
$value = implode(';', $value);
}
$rows[] = [$key, $value];
diff --git a/apps/user_ldap/lib/Command/TestConfig.php b/apps/user_ldap/lib/Command/TestConfig.php
index 6ddd420e4f0..0973e6245b3 100644
--- a/apps/user_ldap/lib/Command/TestConfig.php
+++ b/apps/user_ldap/lib/Command/TestConfig.php
@@ -35,7 +35,6 @@ use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class TestConfig extends Command {
-
protected function configure() {
$this
->setName('ldap:test-config')
@@ -52,17 +51,17 @@ class TestConfig extends Command {
$helper = new Helper(\OC::$server->getConfig());
$availableConfigs = $helper->getServerConfigurationPrefixes();
$configID = $input->getArgument('configID');
- if(!in_array($configID, $availableConfigs)) {
+ if (!in_array($configID, $availableConfigs)) {
$output->writeln("Invalid configID");
return;
}
$result = $this->testConfig($configID);
- if($result === 0) {
+ if ($result === 0) {
$output->writeln('The configuration is valid and the connection could be established!');
- } elseif($result === 1) {
+ } elseif ($result === 1) {
$output->writeln('The configuration is invalid. Please have a look at the logs for further details.');
- } elseif($result === 2) {
+ } elseif ($result === 2) {
$output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.');
} else {
$output->writeln('Your LDAP server was kidnapped by aliens.');
@@ -81,12 +80,12 @@ class TestConfig extends Command {
//ensure validation is run before we attempt the bind
$connection->getConfiguration();
- if(!$connection->setConfiguration([
+ if (!$connection->setConfiguration([
'ldap_configuration_active' => 1,
])) {
return 1;
}
- if($connection->bind()) {
+ if ($connection->bind()) {
return 0;
}
return 2;