From afbd9c4e6ed834e713039f2cff88ba3eec03dadb Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 9 Apr 2020 13:53:40 +0200 Subject: Unify function spacing to PSR2 recommendation Signed-off-by: Christoph Wurst --- apps/files_sharing/lib/AppInfo/Application.php | 8 +++---- .../lib/Collaboration/ShareRecipientSorter.php | 2 +- .../lib/Controller/ShareAPIController.php | 4 ++-- .../lib/Controller/ShareesAPIController.php | 2 +- apps/files_sharing/lib/DeleteOrphanedSharesJob.php | 2 +- apps/files_sharing/lib/MountProvider.php | 2 +- apps/files_sharing/lib/ShareBackend/Folder.php | 2 +- apps/files_sharing/tests/ApiTest.php | 2 +- .../tests/Controller/ShareAPIControllerTest.php | 10 ++++----- .../tests/Controller/ShareControllerTest.php | 26 +++++++++++----------- .../tests/Controller/ShareesAPIControllerTest.php | 2 +- apps/files_sharing/tests/EtagPropagationTest.php | 2 +- apps/files_sharing/tests/External/ManagerTest.php | 2 +- apps/files_sharing/tests/MountProviderTest.php | 8 +++---- apps/files_sharing/tests/SharedMountTest.php | 6 ++--- 15 files changed, 40 insertions(+), 40 deletions(-) (limited to 'apps/files_sharing') diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 14bbe68b446..2539b436592 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -181,7 +181,7 @@ class Application extends App { $server = $c->query('ServerContainer'); return new \OCA\Files_Sharing\External\MountProvider( $server->getDatabaseConnection(), - function() use ($c) { + function () use ($c) { return $c->query('ExternalManager'); }, $server->getCloudIdManager() @@ -215,19 +215,19 @@ class Application extends App { $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalListener::class); $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class); $dispatcher->addServiceListener(ShareCreatedEvent::class, ShareInteractionListener::class); - $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function() { + $dispatcher->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () { \OCP\Util::addScript('files_sharing', 'dist/collaboration'); }); $dispatcher->addServiceListener(ShareCreatedEvent::class, UserShareAcceptanceListener::class); $dispatcher->addServiceListener(UserAddedEvent::class, UserAddedToGroupListener::class); // notifications api to accept incoming user shares - $dispatcher->addListener('OCP\Share::postShare', function(GenericEvent $event) { + $dispatcher->addListener('OCP\Share::postShare', function (GenericEvent $event) { /** @var Listener $listener */ $listener = $this->getContainer()->query(Listener::class); $listener->shareNotification($event); }); - $dispatcher->addListener(IGroup::class . '::postAddUser', function(GenericEvent $event) { + $dispatcher->addListener(IGroup::class . '::postAddUser', function (GenericEvent $event) { /** @var Listener $listener */ $listener = $this->getContainer()->query(Listener::class); $listener->userAddedToGroup($event); diff --git a/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php b/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php index 61952dad15f..6dc0e06d6c6 100644 --- a/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php +++ b/apps/files_sharing/lib/Collaboration/ShareRecipientSorter.php @@ -74,7 +74,7 @@ class ShareRecipientSorter implements ISorter { // at least on PHP 5.6 usort turned out to be not stable. So we add // the current index to the value and compare it on a draw $i = 0; - $workArray = array_map(function($element) use (&$i) { + $workArray = array_map(function ($element) use (&$i) { return [$i++, $element]; }, $byType); diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 68729db6de8..833bc788687 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -602,7 +602,7 @@ class ShareAPIController extends OCSController { $shares = array_merge($userShares, $groupShares, $circleShares, $roomShares); - $shares = array_filter($shares, function(IShare $share) { + $shares = array_filter($shares, function (IShare $share) { return $share->getShareOwner() !== $this->currentUser; }); @@ -639,7 +639,7 @@ class ShareAPIController extends OCSController { $nodes = $folder->getDirectoryListing(); /** @var \OCP\Share\IShare[] $shares */ - $shares = array_reduce($nodes, function($carry, $node) { + $shares = array_reduce($nodes, function ($carry, $node) { $carry = array_merge($carry, $this->getAllShares($node, true)); return $carry; }, []); diff --git a/apps/files_sharing/lib/Controller/ShareesAPIController.php b/apps/files_sharing/lib/Controller/ShareesAPIController.php index 63c96151ebc..898e57c1591 100644 --- a/apps/files_sharing/lib/Controller/ShareesAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareesAPIController.php @@ -257,7 +257,7 @@ class ShareesAPIController extends OCSController { } private function sortShareesByFrequency(array $sharees): array { - usort($sharees, function(array $s1, array $s2) { + usort($sharees, function (array $s1, array $s2) { return $s2['count'] - $s1['count']; }); return $sharees; diff --git a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php index 548da79b9e1..33267a94c4e 100644 --- a/apps/files_sharing/lib/DeleteOrphanedSharesJob.php +++ b/apps/files_sharing/lib/DeleteOrphanedSharesJob.php @@ -41,7 +41,7 @@ class DeleteOrphanedSharesJob extends TimedJob { /** * sets the correct interval for this timed job */ - public function __construct(){ + public function __construct() { $this->interval = $this->defaultIntervalMin * 60; } diff --git a/apps/files_sharing/lib/MountProvider.php b/apps/files_sharing/lib/MountProvider.php index 9845611b180..dd880d13306 100644 --- a/apps/files_sharing/lib/MountProvider.php +++ b/apps/files_sharing/lib/MountProvider.php @@ -155,7 +155,7 @@ class MountProvider implements IMountProvider { $result = []; // sort by stime, the super share will be based on the least recent share foreach ($tmp as &$tmp2) { - @usort($tmp2, function($a, $b) { + @usort($tmp2, function ($a, $b) { if ($a->getShareTime() <= $b->getShareTime()) { return -1; } diff --git a/apps/files_sharing/lib/ShareBackend/Folder.php b/apps/files_sharing/lib/ShareBackend/Folder.php index f2f1e24cc05..7713c8b6b11 100644 --- a/apps/files_sharing/lib/ShareBackend/Folder.php +++ b/apps/files_sharing/lib/ShareBackend/Folder.php @@ -112,7 +112,7 @@ class Folder extends File implements \OCP\Share_Backend_Collection { $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder(); - $parents = array_map(function($parent) use ($qb) { + $parents = array_map(function ($parent) use ($qb) { return $qb->createNamedParameter($parent); }, $parents); diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 654ca3b450b..b8d5a21a739 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -108,7 +108,7 @@ class ApiTest extends TestCase { private function createOCS($userId) { $l = $this->getMockBuilder(IL10N::class)->getMock(); $l->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); $config = $this->createMock(IConfig::class); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 3f82675fedf..577f574f8ed 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -123,7 +123,7 @@ class ShareAPIControllerTest extends TestCase { $this->l = $this->createMock(IL10N::class); $this->l->method('t') - ->willReturnCallback(function($text, $parameters = []) { + ->willReturnCallback(function ($text, $parameters = []) { return vsprintf($text, $parameters); }); $this->config = $this->createMock(IConfig::class); @@ -180,7 +180,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager ->expects($this->exactly(5)) ->method('getShareById') - ->willReturnCallback(function($id) { + ->willReturnCallback(function ($id) { if ($id === 'ocinternal:42' || $id === 'ocRoomShare:42' || $id === 'ocFederatedSharing:42' || $id === 'ocCircleShare:42' || $id === 'ocMailShare:42') { throw new \OCP\Share\Exceptions\ShareNotFound(); } else { @@ -1341,7 +1341,7 @@ class ShareAPIControllerTest extends TestCase { $ocs->method('formatShare') ->willReturnCallback( - function($share) { + function ($share) { return [ 'id' => $share->getId(), 'share_type' => $share->getShareType() @@ -1361,7 +1361,7 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager ->method('getSharesBy') ->willReturnCallback( - function($user, $shareType, $node) use ($shares) { + function ($user, $shareType, $node) use ($shares) { if (!isset($shares[$node->getName()]) || !isset($shares[$node->getName()][$shareType])) { return []; } @@ -1380,7 +1380,7 @@ class ShareAPIControllerTest extends TestCase { $this->groupManager ->method('isInGroup') ->willReturnCallback( - function($user, $group) { + function ($user, $group) { return $group === 'currentUserGroup'; } ); diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 240a0c7faad..a43c050634b 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -284,7 +284,7 @@ class ShareControllerTest extends \Test\TestCase { ->with('core', 'shareapi_public_link_disclaimertext', null) ->willReturn('My disclaimer text'); - $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) { + $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) { if ($uid === 'ownerUID') { return $owner; } @@ -298,14 +298,14 @@ class ShareControllerTest extends \Test\TestCase { ->method('dispatch') ->with( 'OCA\Files_Sharing::loadAdditionalScripts', - $this->callback(function($event) use ($share) { + $this->callback(function ($event) use ($share) { return $event->getArgument('share') === $share; }) ); $this->l10n->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters) { + ->willReturnCallback(function ($text, $parameters) { return vsprintf($text, $parameters); }); @@ -432,7 +432,7 @@ class ShareControllerTest extends \Test\TestCase { ->with('core', 'shareapi_public_link_disclaimertext', null) ->willReturn('My disclaimer text'); - $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) { + $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) { if ($uid === 'ownerUID') { return $owner; } @@ -446,14 +446,14 @@ class ShareControllerTest extends \Test\TestCase { ->method('dispatch') ->with( 'OCA\Files_Sharing::loadAdditionalScripts', - $this->callback(function($event) use ($share) { + $this->callback(function ($event) use ($share) { return $event->getArgument('share') === $share; }) ); $this->l10n->expects($this->any()) ->method('t') - ->will($this->returnCallback(function($text, $parameters) { + ->will($this->returnCallback(function ($text, $parameters) { return vsprintf($text, $parameters); })); @@ -583,7 +583,7 @@ class ShareControllerTest extends \Test\TestCase { ->with('core', 'shareapi_public_link_disclaimertext', null) ->willReturn('My disclaimer text'); - $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) { + $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) { if ($uid === 'ownerUID') { return $owner; } @@ -597,14 +597,14 @@ class ShareControllerTest extends \Test\TestCase { ->method('dispatch') ->with( 'OCA\Files_Sharing::loadAdditionalScripts', - $this->callback(function($event) use ($share) { + $this->callback(function ($event) use ($share) { return $event->getArgument('share') === $share; }) ); $this->l10n->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters) { + ->willReturnCallback(function ($text, $parameters) { return vsprintf($text, $parameters); }); @@ -712,7 +712,7 @@ class ShareControllerTest extends \Test\TestCase { ->with('token') ->willReturn($share); - $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) { + $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) { if ($uid === 'ownerUID') { return $owner; } @@ -724,7 +724,7 @@ class ShareControllerTest extends \Test\TestCase { $this->l10n->expects($this->any()) ->method('t') - ->willReturnCallback(function($text, $parameters) { + ->willReturnCallback(function ($text, $parameters) { return vsprintf($text, $parameters); }); @@ -869,7 +869,7 @@ class ShareControllerTest extends \Test\TestCase { ->with('token') ->willReturn($share); - $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) { + $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) { if ($uid === 'ownerUID') { return $owner; } @@ -910,7 +910,7 @@ class ShareControllerTest extends \Test\TestCase { ->with('token') ->willReturn($share); - $this->userManager->method('get')->willReturnCallback(function(string $uid) use ($owner, $initiator) { + $this->userManager->method('get')->willReturnCallback(function (string $uid) use ($owner, $initiator) { if ($uid === 'ownerUID') { return $owner; } diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php index 0f3f53a26f6..7beb4058c4f 100644 --- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php @@ -292,7 +292,7 @@ class ShareesAPIControllerTest extends TestCase { $this->shareManager->expects($this->any()) ->method('shareProviderExists') - ->willReturnCallback(function($shareType) use ($emailSharingEnabled) { + ->willReturnCallback(function ($shareType) use ($emailSharingEnabled) { if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { return $emailSharingEnabled; } else { diff --git a/apps/files_sharing/tests/EtagPropagationTest.php b/apps/files_sharing/tests/EtagPropagationTest.php index bcab1a92bb8..cb078fdf832 100644 --- a/apps/files_sharing/tests/EtagPropagationTest.php +++ b/apps/files_sharing/tests/EtagPropagationTest.php @@ -456,7 +456,7 @@ class EtagPropagationTest extends PropagationTestCase { $shares = $this->shareManager->getSharesBy(self::TEST_FILES_SHARING_API_USER1, \OCP\Share::SHARE_TYPE_USER, $node); /** @var \OCP\Share\IShare[] $shares */ - $shares = array_filter($shares, function(\OCP\Share\IShare $share) { + $shares = array_filter($shares, function (\OCP\Share\IShare $share) { return $share->getSharedWith() === self::TEST_FILES_SHARING_API_USER2; }); $this->assertCount(1, $shares); diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 5065c88afc7..5a1e8ad14e1 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -110,7 +110,7 @@ class ManagerTest extends TestCase { ] )->setMethods(['tryOCMEndPoint'])->getMock(); - $this->testMountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function() { + $this->testMountProvider = new MountProvider(\OC::$server->getDatabaseConnection(), function () { return $this->manager; }, new CloudIdManager()); } diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php index 66df03101ac..cd1afb1f6ff 100644 --- a/apps/files_sharing/tests/MountProviderTest.php +++ b/apps/files_sharing/tests/MountProviderTest.php @@ -145,7 +145,7 @@ class MountProviderTest extends \Test\TestCase { ->willReturn($roomShares); $this->shareManager->expects($this->any()) ->method('newShare') - ->willReturnCallback(function() use ($rootFolder, $userManager) { + ->willReturnCallback(function () use ($rootFolder, $userManager) { return new \OC\Share20\Share($rootFolder, $userManager); }); $mounts = $this->provider->getMountsForUser($this->user, $this->loader); @@ -322,10 +322,10 @@ class MountProviderTest extends \Test\TestCase { $rootFolder = $this->createMock(IRootFolder::class); $userManager = $this->createMock(IUserManager::class); - $userShares = array_map(function($shareSpec) { + $userShares = array_map(function ($shareSpec) { return $this->makeMockShare($shareSpec[0], $shareSpec[1], $shareSpec[2], $shareSpec[3], $shareSpec[4]); }, $userShares); - $groupShares = array_map(function($shareSpec) { + $groupShares = array_map(function ($shareSpec) { return $this->makeMockShare($shareSpec[0], $shareSpec[1], $shareSpec[2], $shareSpec[3], $shareSpec[4]); }, $groupShares); @@ -354,7 +354,7 @@ class MountProviderTest extends \Test\TestCase { ->willReturn($roomShares); $this->shareManager->expects($this->any()) ->method('newShare') - ->willReturnCallback(function() use ($rootFolder, $userManager) { + ->willReturnCallback(function () use ($rootFolder, $userManager) { return new \OC\Share20\Share($rootFolder, $userManager); }); diff --git a/apps/files_sharing/tests/SharedMountTest.php b/apps/files_sharing/tests/SharedMountTest.php index d2610020ec2..cda01aacba2 100644 --- a/apps/files_sharing/tests/SharedMountTest.php +++ b/apps/files_sharing/tests/SharedMountTest.php @@ -186,7 +186,7 @@ class SharedMountTest extends TestCase { * share file with a group if a user renames the file the filename should not change * for the other users */ - public function testMoveGroupShare () { + public function testMoveGroupShare() { $testGroup = $this->groupManager->createGroup('testGroup'); $user1 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER1); $user2 = $this->userManager->get(self::TEST_FILES_SHARING_API_USER2); @@ -266,7 +266,7 @@ class SharedMountTest extends TestCase { public function dataPermissionMovedGroupShare() { $data = []; - $powerset = function($permissions) { + $powerset = function ($permissions) { $results = [\OCP\Constants::PERMISSION_READ]; foreach ($permissions as $permission) { @@ -460,7 +460,7 @@ class SharedMountTest extends TestCase { } class DummyTestClassSharedMount extends \OCA\Files_Sharing\SharedMount { - public function __construct($storage, $mountpoint, $arguments = null, $loader = null){ + public function __construct($storage, $mountpoint, $arguments = null, $loader = null) { // noop } -- cgit v1.2.3