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 /lib/private/Collaboration | |
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 'lib/private/Collaboration')
11 files changed, 24 insertions, 27 deletions
diff --git a/lib/private/Collaboration/AutoComplete/Manager.php b/lib/private/Collaboration/AutoComplete/Manager.php index d2b490f73f5..e8d5732dec7 100644 --- a/lib/private/Collaboration/AutoComplete/Manager.php +++ b/lib/private/Collaboration/AutoComplete/Manager.php @@ -42,8 +42,8 @@ class Manager implements IManager { public function runSorters(array $sorters, array &$sortArray, array $context) { $sorterInstances = $this->getSorters(); - while($sorter = array_shift($sorters)) { - if(isset($sorterInstances[$sorter])) { + while ($sorter = array_shift($sorters)) { + if (isset($sorterInstances[$sorter])) { $sorterInstances[$sorter]->sort($sortArray, $context); } else { $this->c->getLogger()->warning('No sorter for ID "{id}", skipping', [ @@ -58,17 +58,17 @@ class Manager implements IManager { } protected function getSorters() { - if(count($this->sorterInstances) === 0) { + if (count($this->sorterInstances) === 0) { foreach ($this->sorters as $sorter) { /** @var ISorter $instance */ $instance = $this->c->resolve($sorter); - if(!$instance instanceof ISorter) { + if (!$instance instanceof ISorter) { $this->c->getLogger()->notice('Skipping sorter which is not an instance of ISorter. Class name: {class}', ['app' => 'core', 'class' => $sorter]); continue; } $sorterId = trim($instance->getId()); - if(trim($sorterId) === '') { + if (trim($sorterId) === '') { $this->c->getLogger()->notice('Skipping sorter with empty ID. Class name: {class}', ['app' => 'core', 'class' => $sorter]); continue; diff --git a/lib/private/Collaboration/Collaborators/GroupPlugin.php b/lib/private/Collaboration/Collaborators/GroupPlugin.php index 404d4da8ca2..64db97a5235 100644 --- a/lib/private/Collaboration/Collaborators/GroupPlugin.php +++ b/lib/private/Collaboration/Collaborators/GroupPlugin.php @@ -61,7 +61,9 @@ class GroupPlugin implements ISearchPlugin { $result = ['wide' => [], 'exact' => []]; $groups = $this->groupManager->search($search, $limit, $offset); - $groupIds = array_map(function (IGroup $group) { return $group->getGID(); }, $groups); + $groupIds = array_map(function (IGroup $group) { + return $group->getGID(); + }, $groups); if (!$this->shareeEnumeration || count($groups) < $limit) { $hasMoreResults = true; @@ -71,7 +73,9 @@ class GroupPlugin implements ISearchPlugin { if (!empty($groups) && ($this->shareWithGroupOnly || $this->shareeEnumerationInGroupOnly)) { // Intersect all the groups that match with the groups this user is a member of $userGroups = $this->groupManager->getUserGroups($this->userSession->getUser()); - $userGroups = array_map(function (IGroup $group) { return $group->getGID(); }, $userGroups); + $userGroups = array_map(function (IGroup $group) { + return $group->getGID(); + }, $userGroups); $groupIds = array_intersect($groupIds, $userGroups); } diff --git a/lib/private/Collaboration/Collaborators/LookupPlugin.php b/lib/private/Collaboration/Collaborators/LookupPlugin.php index 493c35a46d4..f0d5b92f18a 100644 --- a/lib/private/Collaboration/Collaborators/LookupPlugin.php +++ b/lib/private/Collaboration/Collaborators/LookupPlugin.php @@ -73,7 +73,7 @@ class LookupPlugin implements ISearchPlugin { } $lookupServerUrl = $this->config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com'); - if(empty($lookupServerUrl)) { + if (empty($lookupServerUrl)) { return false; } $lookupServerUrl = rtrim($lookupServerUrl, '/'); diff --git a/lib/private/Collaboration/Collaborators/MailPlugin.php b/lib/private/Collaboration/Collaborators/MailPlugin.php index bafc383f746..e387e38c6dc 100644 --- a/lib/private/Collaboration/Collaborators/MailPlugin.php +++ b/lib/private/Collaboration/Collaborators/MailPlugin.php @@ -65,7 +65,6 @@ class MailPlugin implements ISearchPlugin { $this->shareeEnumeration = $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes') === 'yes'; $this->shareWithGroupOnly = $this->config->getAppValue('core', 'shareapi_only_share_with_group_members', 'no') === 'yes'; $this->shareeEnumerationInGroupOnly = $this->shareeEnumeration && $this->config->getAppValue('core', 'shareapi_restrict_user_enumeration_to_group', 'no') === 'yes'; - } /** @@ -99,7 +98,7 @@ class MailPlugin implements ISearchPlugin { $emailAddress = $emailAddressData['value']; $emailAddressType = $emailAddressData['type']; } - if (isset($contact['FN'])) { + if (isset($contact['FN'])) { $displayName = $contact['FN'] . ' (' . $emailAddress . ')'; } $exactEmailMatch = strtolower($emailAddress) === $lowerSearch; @@ -179,8 +178,7 @@ class MailPlugin implements ISearchPlugin { } if ($exactEmailMatch - || isset($contact['FN']) && strtolower($contact['FN']) === $lowerSearch) - { + || isset($contact['FN']) && strtolower($contact['FN']) === $lowerSearch) { if ($exactEmailMatch) { $searchResult->markExactIdMatch($emailType); } diff --git a/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php b/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php index a922befec76..777af6093db 100644 --- a/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php +++ b/lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php @@ -90,5 +90,4 @@ class RemoteGroupPlugin implements ISearchPlugin { throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e); } } - } diff --git a/lib/private/Collaboration/Collaborators/Search.php b/lib/private/Collaboration/Collaborators/Search.php index 9b9decfecbe..11c7f87db1d 100644 --- a/lib/private/Collaboration/Collaborators/Search.php +++ b/lib/private/Collaboration/Collaborators/Search.php @@ -56,7 +56,7 @@ class Search implements ISearch { $searchResult = $this->c->resolve(SearchResult::class); foreach ($shareTypes as $type) { - if(!isset($this->pluginList[$type])) { + if (!isset($this->pluginList[$type])) { continue; } foreach ($this->pluginList[$type] as $plugin) { @@ -79,7 +79,7 @@ class Search implements ISearch { // that the exact same email address and federated cloud id exists $emailType = new SearchResultType('emails'); $remoteType = new SearchResultType('remotes'); - if($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) { + if ($searchResult->hasExactIdMatch($emailType) && !$searchResult->hasExactIdMatch($remoteType)) { $searchResult->unsetResult($remoteType); } elseif (!$searchResult->hasExactIdMatch($emailType) && $searchResult->hasExactIdMatch($remoteType)) { $searchResult->unsetResult($emailType); @@ -87,7 +87,7 @@ class Search implements ISearch { // if we have an exact local user match, there is no need to show the remote and email matches $userType = new SearchResultType('users'); - if($searchResult->hasExactIdMatch($userType)) { + if ($searchResult->hasExactIdMatch($userType)) { $searchResult->unsetResult($remoteType); $searchResult->unsetResult($emailType); } @@ -97,7 +97,7 @@ class Search implements ISearch { public function registerPlugin(array $pluginInfo) { $shareType = constant(Share::class . '::' . $pluginInfo['shareType']); - if($shareType === null) { + if ($shareType === null) { throw new \InvalidArgumentException('Provided ShareType is invalid'); } $this->pluginList[$shareType][] = $pluginInfo['class']; diff --git a/lib/private/Collaboration/Collaborators/SearchResult.php b/lib/private/Collaboration/Collaborators/SearchResult.php index 1ee37e65589..46d5894b6f0 100644 --- a/lib/private/Collaboration/Collaborators/SearchResult.php +++ b/lib/private/Collaboration/Collaborators/SearchResult.php @@ -28,7 +28,6 @@ use OCP\Collaboration\Collaborators\ISearchResult; use OCP\Collaboration\Collaborators\SearchResultType; class SearchResult implements ISearchResult { - protected $result = [ 'exact' => [], ]; @@ -37,13 +36,13 @@ class SearchResult implements ISearchResult { public function addResultSet(SearchResultType $type, array $matches, array $exactMatches = null) { $type = $type->getLabel(); - if(!isset($this->result[$type])) { + if (!isset($this->result[$type])) { $this->result[$type] = []; $this->result['exact'][$type] = []; } $this->result[$type] = array_merge($this->result[$type], $matches); - if(is_array($exactMatches)) { + if (is_array($exactMatches)) { $this->result['exact'][$type] = array_merge($this->result['exact'][$type], $exactMatches); } } @@ -58,12 +57,12 @@ class SearchResult implements ISearchResult { public function hasResult(SearchResultType $type, $collaboratorId) { $type = $type->getLabel(); - if(!isset($this->result[$type])) { + if (!isset($this->result[$type])) { return false; } $resultArrays = [$this->result['exact'][$type], $this->result[$type]]; - foreach($resultArrays as $resultArray) { + foreach ($resultArrays as $resultArray) { foreach ($resultArray as $result) { if ($result['value']['shareWith'] === $collaboratorId) { return true; @@ -81,7 +80,7 @@ class SearchResult implements ISearchResult { public function unsetResult(SearchResultType $type) { $type = $type->getLabel(); $this->result[$type] = []; - if(isset($this->result['exact'][$type])) { + if (isset($this->result['exact'][$type])) { $this->result['exact'][$type] = []; } } diff --git a/lib/private/Collaboration/Collaborators/UserPlugin.php b/lib/private/Collaboration/Collaborators/UserPlugin.php index 53dd0c66c7f..189ea2f8ff6 100644 --- a/lib/private/Collaboration/Collaborators/UserPlugin.php +++ b/lib/private/Collaboration/Collaborators/UserPlugin.php @@ -197,7 +197,7 @@ class UserPlugin implements ISearchPlugin { public function takeOutCurrentUser(array &$users) { $currentUser = $this->userSession->getUser(); - if(!is_null($currentUser)) { + if (!is_null($currentUser)) { if (isset($users[$currentUser->getUID()])) { unset($users[$currentUser->getUID()]); } diff --git a/lib/private/Collaboration/Resources/Collection.php b/lib/private/Collaboration/Resources/Collection.php index 827f4e6dd1f..7369b44866d 100644 --- a/lib/private/Collaboration/Resources/Collection.php +++ b/lib/private/Collaboration/Resources/Collection.php @@ -174,7 +174,6 @@ class Collection implements ICollection { } else { $this->manager->invalidateAccessCacheForCollection($this); } - } /** diff --git a/lib/private/Collaboration/Resources/Listener.php b/lib/private/Collaboration/Resources/Listener.php index 608f72ebd5d..240ec7c0649 100644 --- a/lib/private/Collaboration/Resources/Listener.php +++ b/lib/private/Collaboration/Resources/Listener.php @@ -34,7 +34,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; class Listener { - public static function register(EventDispatcherInterface $dispatcher): void { $listener = function (GenericEvent $event) { /** @var IUser $user */ diff --git a/lib/private/Collaboration/Resources/Manager.php b/lib/private/Collaboration/Resources/Manager.php index 98cc25916fe..97213c45669 100644 --- a/lib/private/Collaboration/Resources/Manager.php +++ b/lib/private/Collaboration/Resources/Manager.php @@ -42,7 +42,6 @@ use OCP\ILogger; use OCP\IUser; class Manager implements IManager { - public const TABLE_COLLECTIONS = 'collres_collections'; public const TABLE_RESOURCES = 'collres_resources'; public const TABLE_ACCESS_CACHE = 'collres_accesscache'; |