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/sharebymail | |
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/sharebymail')
-rw-r--r-- | apps/sharebymail/lib/Activity.php | 1 | ||||
-rw-r--r-- | apps/sharebymail/lib/AppInfo/Application.php | 2 | ||||
-rw-r--r-- | apps/sharebymail/lib/Settings/Admin.php | 2 | ||||
-rw-r--r-- | apps/sharebymail/lib/Settings/SettingsManager.php | 1 | ||||
-rw-r--r-- | apps/sharebymail/lib/ShareByMailProvider.php | 27 | ||||
-rw-r--r-- | apps/sharebymail/templates/settings-admin.php | 8 | ||||
-rw-r--r-- | apps/sharebymail/tests/SettingsTest.php | 3 | ||||
-rw-r--r-- | apps/sharebymail/tests/ShareByMailProviderTest.php | 10 |
8 files changed, 14 insertions, 40 deletions
diff --git a/apps/sharebymail/lib/Activity.php b/apps/sharebymail/lib/Activity.php index 279055538d9..757b2692e86 100644 --- a/apps/sharebymail/lib/Activity.php +++ b/apps/sharebymail/lib/Activity.php @@ -272,7 +272,6 @@ class Activity implements IProvider { } else { $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/share.svg'))); } - } else { throw new \InvalidArgumentException(); } diff --git a/apps/sharebymail/lib/AppInfo/Application.php b/apps/sharebymail/lib/AppInfo/Application.php index d294f9716ea..7acb43cfbed 100644 --- a/apps/sharebymail/lib/AppInfo/Application.php +++ b/apps/sharebymail/lib/AppInfo/Application.php @@ -32,7 +32,6 @@ use OCP\AppFramework\App; use OCP\Util; class Application extends App { - public function __construct(array $urlParams = []) { parent::__construct('sharebymail', $urlParams); @@ -47,5 +46,4 @@ class Application extends App { Util::connectHook('\OCP\Config', 'js', $settings, 'announceShareProvider'); Util::connectHook('\OCP\Config', 'js', $settings, 'announceShareByMailSettings'); } - } diff --git a/apps/sharebymail/lib/Settings/Admin.php b/apps/sharebymail/lib/Settings/Admin.php index 251269293ef..23881212692 100644 --- a/apps/sharebymail/lib/Settings/Admin.php +++ b/apps/sharebymail/lib/Settings/Admin.php @@ -39,7 +39,6 @@ class Admin implements ISettings { * @return TemplateResponse */ public function getForm() { - $parameters = [ 'sendPasswordMail' => $this->settingsManager->sendPasswordByMail(), 'enforcePasswordProtection' => $this->settingsManager->enforcePasswordProtection() @@ -65,5 +64,4 @@ class Admin implements ISettings { public function getPriority() { return 40; } - } diff --git a/apps/sharebymail/lib/Settings/SettingsManager.php b/apps/sharebymail/lib/Settings/SettingsManager.php index 8e784e80237..cded3e1713d 100644 --- a/apps/sharebymail/lib/Settings/SettingsManager.php +++ b/apps/sharebymail/lib/Settings/SettingsManager.php @@ -57,5 +57,4 @@ class SettingsManager { $enforcePassword = $this->config->getAppValue('sharebymail', 'enforcePasswordProtection', $this->enforcePasswordProtectionDefault); return $enforcePassword === 'yes'; } - } diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php index 220f3e6454b..4292ac9bf18 100644 --- a/apps/sharebymail/lib/ShareByMailProvider.php +++ b/apps/sharebymail/lib/ShareByMailProvider.php @@ -173,7 +173,6 @@ class ShareByMailProvider implements IShareProvider { * @throws \Exception */ public function create(IShare $share) { - $shareWith = $share->getSharedWith(); /* * Check if file is not already shared with the remote user @@ -204,7 +203,6 @@ class ShareByMailProvider implements IShareProvider { $data = $this->getRawShare($shareId); return $this->createShareObject($data); - } /** @@ -261,7 +259,6 @@ class ShareByMailProvider implements IShareProvider { * @param string $type */ protected function createShareActivity(IShare $share, string $type = 'share') { - $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy()); $this->publishActivity( @@ -285,7 +282,6 @@ class ShareByMailProvider implements IShareProvider { (string) $ownerFolder->getRelativePath($ownerPath) ); } - } /** @@ -296,7 +292,6 @@ class ShareByMailProvider implements IShareProvider { * @param bool $sendToSelf */ protected function createPasswordSendActivity(IShare $share, $sharedWith, $sendToSelf) { - $userFolder = $this->rootFolder->getUserFolder($share->getSharedBy()); if ($sendToSelf) { @@ -336,7 +331,6 @@ class ShareByMailProvider implements IShareProvider { ->setAffectedUser($affectedUser) ->setObject('files', $fileId, $filePath); $this->activityManager->publish($event); - } /** @@ -389,7 +383,6 @@ class ShareByMailProvider implements IShareProvider { } return $shareId; - } /** @@ -447,7 +440,7 @@ class ShareByMailProvider implements IShareProvider { // The "Reply-To" is set to the sharer if an mail address is configured // also the default footer contains a "Do not reply" which needs to be adjusted. $initiatorEmail = $initiatorUser->getEMailAddress(); - if($initiatorEmail !== null) { + if ($initiatorEmail !== null) { $message->setReplyTo([$initiatorEmail => $initiatorDisplayName]); $emailTemplate->addFooter($instanceName . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')); } else { @@ -466,7 +459,6 @@ class ShareByMailProvider implements IShareProvider { * @return bool */ protected function sendPassword(IShare $share, $password) { - $filename = $share->getNode()->getName(); $initiator = $share->getSharedBy(); $shareWith = $share->getSharedWith(); @@ -526,7 +518,6 @@ class ShareByMailProvider implements IShareProvider { } protected function sendNote(IShare $share) { - $recipient = $share->getSharedWith(); @@ -577,7 +568,6 @@ class ShareByMailProvider implements IShareProvider { $message->setTo([$recipient]); $message->useTemplate($emailTemplate); $this->mailer->send($message); - } /** @@ -590,7 +580,6 @@ class ShareByMailProvider implements IShareProvider { * @throws \Exception */ protected function sendPasswordToOwner(IShare $share, $password) { - $filename = $share->getNode()->getName(); $initiator = $this->userManager->get($share->getSharedBy()); $initiatorEMailAddress = ($initiator instanceof IUser) ? $initiator->getEMailAddress() : null; @@ -668,7 +657,7 @@ class ShareByMailProvider implements IShareProvider { ->orderBy('id'); $cursor = $qb->execute(); - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { $children[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -728,13 +717,12 @@ class ShareByMailProvider implements IShareProvider { * @return IShare The share object */ public function update(IShare $share, $plainTextPassword = null) { - $originalShare = $this->getShareById($share->getId()); // a real password was given $validPassword = $plainTextPassword !== null && $plainTextPassword !== ''; - if($validPassword && ($originalShare->getPassword() !== $share->getPassword() || + if ($validPassword && ($originalShare->getPassword() !== $share->getPassword() || ($originalShare->getSendPasswordByTalk() && !$share->getSendPasswordByTalk()))) { $this->sendPassword($share, $plainTextPassword); } @@ -844,7 +832,7 @@ class ShareByMailProvider implements IShareProvider { $cursor = $qb->execute(); $shares = []; - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -896,7 +884,7 @@ class ShareByMailProvider implements IShareProvider { ->execute(); $shares = []; - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -935,7 +923,7 @@ class ShareByMailProvider implements IShareProvider { $cursor = $qb->execute(); - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { $shares[] = $this->createShareObject($data); } $cursor->closeCursor(); @@ -996,7 +984,6 @@ class ShareByMailProvider implements IShareProvider { * @throws ShareNotFound */ protected function createShareObject($data) { - $share = new Share($this->rootFolder, $this->userManager); $share->setId((int)$data['id']) ->setShareType((int)$data['share_type']) @@ -1204,7 +1191,7 @@ class ShareByMailProvider implements IShareProvider { ); $cursor = $qb->execute(); - while($data = $cursor->fetch()) { + while ($data = $cursor->fetch()) { try { $share = $this->createShareObject($data); } catch (InvalidShare $e) { diff --git a/apps/sharebymail/templates/settings-admin.php b/apps/sharebymail/templates/settings-admin.php index 5b16f551a56..52b9ea29593 100644 --- a/apps/sharebymail/templates/settings-admin.php +++ b/apps/sharebymail/templates/settings-admin.php @@ -10,9 +10,13 @@ style('sharebymail', 'settings-admin'); <p class="settings-hint"><?php p($l->t('Allows users to share a personalized link to a file or folder by putting in an email address.')); ?></p> <p> - <input id="sendPasswordMail" type="checkbox" class="checkbox" <?php if($_['sendPasswordMail']) p('checked'); ?> /> + <input id="sendPasswordMail" type="checkbox" class="checkbox" <?php if ($_['sendPasswordMail']) { + p('checked'); +} ?> /> <label for="sendPasswordMail"><?php p($l->t('Send password by mail')); ?></label><br/> - <input id="enforcePasswordProtection" type="checkbox" class="checkbox" <?php if($_['enforcePasswordProtection']) p('checked'); ?> /> + <input id="enforcePasswordProtection" type="checkbox" class="checkbox" <?php if ($_['enforcePasswordProtection']) { + p('checked'); +} ?> /> <label for="enforcePasswordProtection"><?php p($l->t('Enforce password protection')); ?></label> </p> diff --git a/apps/sharebymail/tests/SettingsTest.php b/apps/sharebymail/tests/SettingsTest.php index 220f455a26a..83bf12da21e 100644 --- a/apps/sharebymail/tests/SettingsTest.php +++ b/apps/sharebymail/tests/SettingsTest.php @@ -28,7 +28,7 @@ use OCA\ShareByMail\Settings; use OCA\ShareByMail\Settings\SettingsManager; use Test\TestCase; -class SettingsTest extends TestCase { +class SettingsTest extends TestCase { /** @var Settings */ private $instance; @@ -93,5 +93,4 @@ class SettingsTest extends TestCase { $this->instance->announceShareByMailSettings(['array' => &$before]); $this->assertSame($after, $before); } - } diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php index f340fbfa35d..f77b3afefce 100644 --- a/apps/sharebymail/tests/ShareByMailProviderTest.php +++ b/apps/sharebymail/tests/ShareByMailProviderTest.php @@ -139,7 +139,6 @@ class ShareByMailProviderTest extends TestCase { * @return \PHPUnit_Framework_MockObject_MockObject | ShareByMailProvider */ private function getInstance(array $mockedMethods = []) { - $instance = $this->getMockBuilder('OCA\ShareByMail\ShareByMailProvider') ->setConstructorArgs( [ @@ -179,7 +178,6 @@ class ShareByMailProviderTest extends TestCase { $this->hasher, $this->capabilitiesManager ); - } protected function tearDown(): void { @@ -353,7 +351,6 @@ class ShareByMailProviderTest extends TestCase { $this->assertSame(42, $this->invokePrivate($instance, 'createMailShare', [$this->share]) ); - } @@ -383,7 +380,6 @@ class ShareByMailProviderTest extends TestCase { $this->assertSame(42, $this->invokePrivate($instance, 'createMailShare', [$this->share]) ); - } public function testGenerateToken() { @@ -445,11 +441,9 @@ class ShareByMailProviderTest extends TestCase { $this->assertSame($password, $result[0]['password']); $this->assertSame($sendPasswordByTalk, (bool)$result[0]['password_by_talk']); $this->assertSame($hideDownload, (bool)$result[0]['hide_download']); - } public function testUpdate() { - $itemSource = 11; $itemType = 'file'; $shareWith = 'user@server.com'; @@ -603,7 +597,6 @@ class ShareByMailProviderTest extends TestCase { } public function testGetShareByPath() { - $itemSource = 11; $itemType = 'file'; $shareWith = 'user@server.com'; @@ -639,7 +632,6 @@ class ShareByMailProviderTest extends TestCase { } public function testGetShareByToken() { - $itemSource = 11; $itemType = 'file'; $shareWith = 'user@server.com'; @@ -726,7 +718,6 @@ class ShareByMailProviderTest extends TestCase { } public function testUserDeleted() { - $itemSource = 11; $itemType = 'file'; $shareWith = 'user@server.com'; @@ -757,7 +748,6 @@ class ShareByMailProviderTest extends TestCase { $this->assertTrue(is_array($after)); $this->assertSame(1, count($after)); $this->assertSame($id, (int)$after[0]['id']); - } public function testGetRawShare() { |