diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2020-08-13 17:40:02 +0300 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2020-08-13 17:40:02 +0300 |
commit | 9bba102a8434c42da4f0a6e89179dc1e7cfb9e70 (patch) | |
tree | 92d5375549d19b0d6fd098d29c391f6adda49ec2 /lib | |
parent | ff2991a6b1d95057827bf1a70dc48227852c6335 (diff) |
cleaning
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
36 files changed, 165 insertions, 186 deletions
diff --git a/lib/Activity/Provider.php b/lib/Activity/Provider.php index 8cc414d9..e8fcdae8 100644 --- a/lib/Activity/Provider.php +++ b/lib/Activity/Provider.php @@ -25,6 +25,7 @@ * */ + namespace OCA\Circles\Activity; use Exception; @@ -39,8 +40,13 @@ use OCA\Circles\Service\MiscService; use OCP\Activity\IEvent; use OCP\Activity\IManager; use OCP\Activity\IProvider; -use OpenCloud\Common\Exceptions\InvalidArgumentError; + +/** + * Class Provider + * + * @package OCA\Circles\Activity + */ class Provider implements IProvider { @@ -132,7 +138,6 @@ class Provider implements IProvider { } - /** * @param IEvent $event * @param Circle $circle @@ -189,10 +194,9 @@ class Provider implements IProvider { * @param Circle $circle * @param array $params * - * @throws InvalidArgumentError + * @throws FakeException */ private function parseMemberAsMember(IEvent $event, Circle $circle, $params) { - if (!key_exists('member', $params)) { return; } @@ -210,6 +214,8 @@ class Provider implements IProvider { * @param IEvent $event * @param Circle $circle * @param array $params + * + * @throws FakeException */ private function parseGroupAsModerator(IEvent $event, Circle $circle, $params) { if (!key_exists('group', $params)) { @@ -228,6 +234,8 @@ class Provider implements IProvider { * @param IEvent $event * @param Circle $circle * @param array $params + * + * @throws FakeException */ private function parseMemberAsModerator(IEvent $event, Circle $circle, $params) { if (!key_exists('member', $params)) { @@ -247,6 +255,8 @@ class Provider implements IProvider { * @param IEvent $event * @param Circle $circle * @param array $params + * + * @throws FakeException */ private function parseLinkAsModerator(IEvent $event, Circle $circle, $params) { diff --git a/lib/Api/Circles.php b/lib/Api/Circles.php index 1e0f58a6..c6995f23 100644 --- a/lib/Api/Circles.php +++ b/lib/Api/Circles.php @@ -27,6 +27,7 @@ namespace OCA\Circles\Api; +use OC; use OCA\Circles\AppInfo\Application; use OCA\Circles\Model\Circle; use OCA\Circles\Model\FederatedLink; @@ -47,7 +48,7 @@ class Circles { * @return Circle */ public static function detailsCircle($circleId) { - $app = \OC::$server->query(Application::class); + $app = OC::$server->query(Application::class); $c = $app->getContainer(); return $c->query(CirclesService::class) diff --git a/lib/Api/v1/Circles.php b/lib/Api/v1/Circles.php index fa4b60e8..0fe9eb5f 100644 --- a/lib/Api/v1/Circles.php +++ b/lib/Api/v1/Circles.php @@ -30,6 +30,7 @@ namespace OCA\Circles\Api\v1; +use OC; use OCA\Circles\AppInfo\Application; use OCA\Circles\Exceptions\ApiVersionIncompatibleException; use OCA\Circles\Model\Circle; @@ -65,10 +66,10 @@ class Circles { const LEVEL_MODERATOR = Member::LEVEL_MODERATOR; const LEVEL_ADMIN = Member::LEVEL_ADMIN; const LEVEL_OWNER = Member::LEVEL_OWNER; - + protected static function getContainer() { - $app = \OC::$server->query(Application::class); + $app = OC::$server->query(Application::class); return $app->getContainer(); } @@ -130,7 +131,6 @@ class Circles { * @param string $name * * @return Circle - * @throws QueryException */ public static function createCircle($type, $name) { $c = self::getContainer(); @@ -148,7 +148,6 @@ class Circles { * @param string $circleUniqueId * * @return Member - * @throws QueryException */ public static function joinCircle($circleUniqueId) { $c = self::getContainer(); @@ -167,7 +166,6 @@ class Circles { * @param string $circleUniqueId * * @return Member - * @throws QueryException */ public static function leaveCircle($circleUniqueId) { $c = self::getContainer(); @@ -195,13 +193,12 @@ class Circles { * @param bool $forceAll * * @return Circle[] - * @throws QueryException */ public static function listCircles($type, $name = '', $level = 0, $userId = '', $forceAll = false) { $c = self::getContainer(); if ($userId === '') { - $userId = \OC::$server->getUserSession() + $userId = OC::$server->getUserSession() ->getUser() ->getUID(); } @@ -261,7 +258,6 @@ class Circles { * @param bool $forceAll * * @return Circle - * @throws QueryException */ public static function detailsCircle($circleUniqueId, $forceAll = false) { $c = self::getContainer(); @@ -280,7 +276,6 @@ class Circles { * @param array $settings * * @return Circle - * @throws QueryException */ public static function settingsCircle($circleUniqueId, array $settings) { $c = self::getContainer(); @@ -298,7 +293,6 @@ class Circles { * @param string $circleUniqueId * * @return mixed - * @throws QueryException */ public static function destroyCircle($circleUniqueId) { $c = self::getContainer(); @@ -319,7 +313,6 @@ class Circles { * @param int $type * * @return Member[] - * @throws QueryException */ public static function addMember($circleUniqueId, $ident, $type) { $c = self::getContainer(); @@ -341,7 +334,6 @@ class Circles { * @param bool $forceAll * * @return Member - * @throws QueryException */ public static function getMember($circleUniqueId, $ident, $type, $forceAll = false) { $c = self::getContainer(); @@ -362,7 +354,6 @@ class Circles { * @param int $type * * @return Member[] - * @throws QueryException */ public static function removeMember($circleUniqueId, $ident, $type) { $c = self::getContainer(); @@ -386,7 +377,6 @@ class Circles { * @param int $level * * @return Member[] - * @throws QueryException */ public static function levelMember($circleUniqueId, $ident, $type, $level) { $c = self::getContainer(); @@ -410,7 +400,6 @@ class Circles { * @param string $broadcaster * * @return mixed - * @throws QueryException */ public static function shareToCircle( $circleUniqueId, $source, $type, array $payload, $broadcaster @@ -434,7 +423,6 @@ class Circles { * @param string $circleUniqueId * * @return mixed - * @throws QueryException */ public static function getSharesFromCircle($circleUniqueId) { $c = self::getContainer(); @@ -456,7 +444,6 @@ class Circles { * @param string $remote * * @return FederatedLink - * @throws QueryException */ public static function linkCircle($circleUniqueId, $remote) { $c = self::getContainer(); @@ -476,7 +463,7 @@ class Circles { * @return string */ public static function generateLink($circleUniqueId) { - return \OC::$server->getURLGenerator() + return OC::$server->getURLGenerator() ->linkToRoute('circles.Navigation.navigate') . '#' . $circleUniqueId; } @@ -491,7 +478,7 @@ class Circles { * @return string */ public static function generateAbsoluteLink($circleUniqueId) { - return \OC::$server->getURLGenerator() + return OC::$server->getURLGenerator() ->linkToRouteAbsolute('circles.Navigation.navigate') . '#' . $circleUniqueId; } @@ -506,7 +493,7 @@ class Circles { * @return string */ public static function generateRemoteLink(FederatedLink $link) { - return \OC::$server->getURLGenerator() + return OC::$server->getURLGenerator() ->linkToRoute('circles.Navigation.navigate') . '#' . $link->getUniqueId() . '-' . $link->getToken(); } @@ -560,7 +547,6 @@ class Circles { * @param array $circleUniqueIds * * @return string[] array of object ids or empty array if none found - * @throws QueryException */ public static function getFilesForCircles($circleUniqueIds) { $c = self::getContainer(); diff --git a/lib/Circles/FileSharingBroadcaster.php b/lib/Circles/FileSharingBroadcaster.php index 229f16d9..fa2a48fe 100644 --- a/lib/Circles/FileSharingBroadcaster.php +++ b/lib/Circles/FileSharingBroadcaster.php @@ -44,8 +44,6 @@ use OCA\Circles\Service\MiscService; use OCA\FederatedFileSharing\Notifications; use OCP\AppFramework\QueryException; use OCP\Defaults; -use OCP\Federation\ICloudFederationFactory; -use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\ICloudIdManager; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; @@ -79,12 +77,6 @@ class FileSharingBroadcaster implements IBroadcaster { /** @var IUserManager */ private $userManager; - /** @var ICloudFederationFactory */ - private $federationFactory; - - /** @var ICloudFederationProviderManager */ - private $federationProviderManager; - /** @var ICloudIdManager */ private $federationCloudIdManager; @@ -115,6 +107,7 @@ class FileSharingBroadcaster implements IBroadcaster { /** @var bool */ private $federatedEnabled = false; + /** * {@inheritdoc} */ @@ -128,8 +121,6 @@ class FileSharingBroadcaster implements IBroadcaster { $this->mailer = OC::$server->getMailer(); $this->rootFolder = OC::$server->getLazyRootFolder(); $this->userManager = OC::$server->getUserManager(); - $this->federationFactory = OC::$server->getCloudFederationFactory(); - $this->federationProviderManager = OC::$server->getCloudFederationProviderManager(); $this->federationCloudIdManager = OC::$server->getCloudIdManager(); $this->logger = OC::$server->getLogger(); $this->urlGenerator = OC::$server->getURLGenerator(); @@ -348,7 +339,7 @@ class FileSharingBroadcaster implements IBroadcaster { * @param Circle $circle * @param IShare $share * @param string $address - * @param string $token + * @param SharesToken $token * * @return bool */ @@ -361,11 +352,11 @@ class FileSharingBroadcaster implements IBroadcaster { $sharedByFederatedId = $share->getSharedBy(); if ($this->userManager->userExists($sharedByFederatedId)) { $cloudId = $this->federationCloudIdManager->getCloudId($sharedByFederatedId, $localUrl); - $sharedByFederatedId = $cloudId->getId(); } + $sharedByFederatedId = $cloudId->getId(); $ownerCloudId = $this->federationCloudIdManager->getCloudId($share->getShareOwner(), $localUrl); - $send = $this->federationNotifications->sendRemoteShare( + return $this->federationNotifications->sendRemoteShare( $token->getToken(), $address, $share->getNode() @@ -377,8 +368,6 @@ class FileSharingBroadcaster implements IBroadcaster { $sharedByFederatedId, Share::TYPE_USER ); - - return $send; } catch (\Exception $e) { $this->logger->logException( $e, [ diff --git a/lib/Command/Groups.php b/lib/Command/Groups.php index fe6505d3..ab35447a 100644 --- a/lib/Command/Groups.php +++ b/lib/Command/Groups.php @@ -32,7 +32,6 @@ use OCA\Circles\Db\CirclesRequest; use OCA\Circles\Exceptions\CommandMissingArgumentException; use OCA\Circles\Exceptions\FakeException; use OCP\IL10N; -use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -106,6 +105,7 @@ class Groups extends Base { * @param OutputInterface $output * * @throws FakeException + * @throws CommandMissingArgumentException */ private function addLinkedGroups(InputInterface $input, OutputInterface $output) { if ($input->getOption('link') !== true) { diff --git a/lib/Controller/BaseController.php b/lib/Controller/BaseController.php index 58ef1b0c..b33e2823 100644 --- a/lib/Controller/BaseController.php +++ b/lib/Controller/BaseController.php @@ -98,6 +98,7 @@ class BaseController extends Controller { * @param SearchService $searchService * @param MembersService $membersService * @param GSUpstreamService $gsUpstreamService + * @param GSDownstreamService $gsDownstreamService * @param GroupsService $groupsService * @param SharingFrameService $sharingFrameService * @param BroadcastService $broadcastService diff --git a/lib/Controller/FederatedController.php b/lib/Controller/FederatedController.php index b87cdc27..ea0f3890 100644 --- a/lib/Controller/FederatedController.php +++ b/lib/Controller/FederatedController.php @@ -30,6 +30,7 @@ use Exception; use OC\AppFramework\Http; use OCA\Circles\Api\v1\Circles; use OCA\Circles\Exceptions\CircleDoesNotExistException; +use OCA\Circles\Exceptions\MissingKeyInArrayException; use OCA\Circles\Exceptions\SharingFrameAlreadyExistException; use OCA\Circles\Model\FederatedLink; use OCA\Circles\Model\SharingFrame; @@ -144,6 +145,7 @@ class FederatedController extends Controller { * @param $data * * @return FederatedLink + * @throws MissingKeyInArrayException */ private function generateNewLink($data) { MiscService::mustContains($data, ['token', 'uniqueId', 'sourceName', 'address']); @@ -176,6 +178,7 @@ class FederatedController extends Controller { * @param string $item * * @return DataResponse + * @throws Exception */ public function receiveFederatedDelivery($apiVersion, $token, $uniqueId, $item) { diff --git a/lib/Controller/GroupsController.php b/lib/Controller/GroupsController.php index 311eafa8..fffc023e 100644 --- a/lib/Controller/GroupsController.php +++ b/lib/Controller/GroupsController.php @@ -27,6 +27,7 @@ namespace OCA\Circles\Controller; use Exception; +use OCA\Circles\Exceptions\GSStatusException; use OCA\Circles\Exceptions\LinkedGroupNotAllowedException; use OCP\AppFramework\Http\DataResponse; @@ -42,6 +43,7 @@ class GroupsController extends BaseController { * * @return DataResponse * @throws LinkedGroupNotAllowedException + * @throws GSStatusException */ public function add($uniqueId, $name) { if (!$this->configService->isLinkedGroupsAllowed()) { diff --git a/lib/Controller/NavigationController.php b/lib/Controller/NavigationController.php index 631517e5..a2377d72 100644 --- a/lib/Controller/NavigationController.php +++ b/lib/Controller/NavigationController.php @@ -27,12 +27,9 @@ namespace OCA\Circles\Controller; use Exception; -use OCA\Circles\Api\v1\Circles; -use OCA\Circles\Api\v1\ShotgunCircles; use OCA\Circles\AppInfo\Application; use OCA\Circles\Model\Circle; use OCA\Circles\Service\ConfigService; -use OCA\Testing\Config; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\TemplateResponse; diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index ac754409..a4cf026f 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -29,7 +29,7 @@ class SettingsController extends Controller { * @NoCSRFRequired */ public function getSettings() { - $params = [ + return [ 'membersLimit' => $this->configService->getAppValue( ConfigService::CIRCLES_MEMBERS_LIMIT ), @@ -43,8 +43,6 @@ class SettingsController extends Controller { ConfigService::CIRCLES_SKIP_INVITATION_STEP ) ]; - - return $params; } diff --git a/lib/Controller/SharesController.php b/lib/Controller/SharesController.php index 30d03ca5..2cdb7756 100644 --- a/lib/Controller/SharesController.php +++ b/lib/Controller/SharesController.php @@ -141,6 +141,7 @@ class SharesController extends Controller { $this->sharingFrameService->createFrame($circleUniqueId, $share); } catch (\Exception $e) { $this->miscService->log('Failed to create circle - ' . $e->getMessage(), 3); + return $this->fail( [ 'circle_id' => $circleUniqueId, @@ -185,6 +186,7 @@ class SharesController extends Controller { * @param string $frameId * * @return DataResponse + * @throws Exception */ public function initShareDelivery($circleId, $frameId) { diff --git a/lib/Cron/ContactsExistingShares.php b/lib/Cron/ContactsExistingShares.php index a9f36977..f92888a2 100644 --- a/lib/Cron/ContactsExistingShares.php +++ b/lib/Cron/ContactsExistingShares.php @@ -40,6 +40,7 @@ use OCA\Circles\Db\MembersRequest; use OCA\Circles\Db\SharesRequest; use OCA\Circles\Db\TokensRequest; use OCA\Circles\Exceptions\CircleDoesNotExistException; +use OCA\Circles\Exceptions\GSStatusException; use OCA\Circles\Exceptions\MemberDoesNotExistException; use OCA\Circles\Exceptions\TokenDoesNotExistException; use OCA\Circles\Model\Member; @@ -47,7 +48,6 @@ use OCA\Circles\Model\SharesToken; use OCA\Circles\Service\ConfigService; use OCA\Circles\Service\DavService; use OCA\Circles\Service\MiscService; -use OCP\AppFramework\QueryException; use OCP\Files\IRootFolder; use OCP\IUserManager; use OCP\Share\Exceptions\IllegalIDChangeException; @@ -89,9 +89,6 @@ class ContactsExistingShares extends TimedJob { /** @var FileSharingBroadcaster */ private $fileSharingBroadcaster; - /** @var ConfigService */ - private $configService; - /** @var MiscService */ private $miscService; @@ -106,8 +103,6 @@ class ContactsExistingShares extends TimedJob { /** * @param mixed $argument - * - * @throws QueryException */ protected function run($argument) { $app = \OC::$server->query(Application::class); @@ -121,10 +116,10 @@ class ContactsExistingShares extends TimedJob { $this->tokensRequest = $c->query(TokensRequest::class); $this->sharesRequest = $c->query(SharesRequest::class); $this->fileSharingBroadcaster = $c->query(FileSharingBroadcaster::class); - $this->configService = $c->query(ConfigService::class); $this->miscService = $c->query(MiscService::class); - if (!$this->configService->isContactsBackend()) { + $configService = $c->query(ConfigService::class); + if (!$configService->isContactsBackend()) { return; } @@ -136,6 +131,7 @@ class ContactsExistingShares extends TimedJob { /** * @return Member[] + * @throws GSStatusException */ private function getNewMembers(): array { $knownMembers = $this->membersRequest->forceGetAllRecentContactEdit(); diff --git a/lib/Db/CircleProviderRequest.php b/lib/Db/CircleProviderRequest.php index 35aac339..c97c772b 100644 --- a/lib/Db/CircleProviderRequest.php +++ b/lib/Db/CircleProviderRequest.php @@ -28,6 +28,8 @@ namespace OCA\Circles\Db; +use OCA\Circles\Exceptions\GSStatusException; + class CircleProviderRequest extends CircleProviderRequestBuilder { @@ -38,6 +40,7 @@ class CircleProviderRequest extends CircleProviderRequestBuilder { * @param $offset * * @return array + * @throws GSStatusException */ public function getFilesForCircles($userId, $circleUniqueIds, $limit, $offset) { diff --git a/lib/Db/CirclesRequest.php b/lib/Db/CirclesRequest.php index dd613862..751df7a2 100644 --- a/lib/Db/CirclesRequest.php +++ b/lib/Db/CirclesRequest.php @@ -124,9 +124,7 @@ class CirclesRequest extends CirclesRequestBuilder { throw new CircleDoesNotExistException($this->l10n->t('Circle not found')); } - $entry = $this->parseCirclesSelectSql($data); - - return $entry; + return $this->parseCirclesSelectSql($data); } @@ -323,6 +321,7 @@ class CirclesRequest extends CirclesRequestBuilder { * @param string $userId * * @throws CircleAlreadyExistsException + * @throws ConfigNoCircleAvailableException */ public function updateCircle(Circle $circle, $userId = '') { if (!$this->isCircleUnique($circle, $userId)) { @@ -358,9 +357,7 @@ class CirclesRequest extends CirclesRequestBuilder { throw new CircleDoesNotExistException($this->l10n->t('Circle not found')); } - $entry = $this->parseCirclesSelectSql($data); - - return $entry; + return $this->parseCirclesSelectSql($data); } diff --git a/lib/Db/CirclesRequestBuilder.php b/lib/Db/CirclesRequestBuilder.php index 5a36d19d..e0f44286 100644 --- a/lib/Db/CirclesRequestBuilder.php +++ b/lib/Db/CirclesRequestBuilder.php @@ -66,7 +66,7 @@ class CirclesRequestBuilder extends CoreRequestBuilder { * * @param IQueryBuilder $qb */ - protected function limitToNonPersonalCircle(IQueryBuilder &$qb) { + protected function limitToNonPersonalCircle(IQueryBuilder $qb) { $expr = $qb->expr(); $qb->andWhere( @@ -86,7 +86,7 @@ class CirclesRequestBuilder extends CoreRequestBuilder { * @throws ConfigNoCircleAvailableException */ protected function limitRegardingCircleType( - IQueryBuilder &$qb, string $userId, $circleUniqueId, int $type, + IQueryBuilder $qb, string $userId, $circleUniqueId, int $type, string $name, bool $forceAll = false ) { $orTypes = $this->generateLimit($qb, $circleUniqueId, $userId, $type, $name, $forceAll); @@ -119,7 +119,7 @@ class CirclesRequestBuilder extends CoreRequestBuilder { * @return array */ private function generateLimit( - IQueryBuilder &$qb, $circleUniqueId, $userId, $type, $name, $forceAll = false + IQueryBuilder $qb, $circleUniqueId, $userId, $type, $name, $forceAll = false ) { $orTypes = []; array_push($orTypes, $this->generateLimitPersonal($qb, $userId, $type, $forceAll)); @@ -178,18 +178,16 @@ class CirclesRequestBuilder extends CoreRequestBuilder { if ($name !== '') { $orX->add($expr->eq('c.alt_name', $qb->createNamedParameter($name))); } - + if ($this->leftJoinedNCGroupAndUser) { $orX->add($expr->gte('g.level', $qb->createNamedParameter(Member::LEVEL_MEMBER))); } /** @noinspection PhpMethodParametersCountMismatchInspection */ - $sqb = $expr->andX( + return $expr->andX( $expr->eq('c.type', $qb->createNamedParameter(Circle::CIRCLES_SECRET)), $expr->orX($orX) ); - - return $sqb; } @@ -240,7 +238,7 @@ class CirclesRequestBuilder extends CoreRequestBuilder { * @param int $type * @param string $instanceId */ - public function leftJoinUserIdAsViewer(IQueryBuilder &$qb, string $userId, int $type, string $instanceId + public function leftJoinUserIdAsViewer(IQueryBuilder $qb, string $userId, int $type, string $instanceId ) { if ($qb->getType() !== QueryBuilder::SELECT) { return; @@ -275,7 +273,7 @@ class CirclesRequestBuilder extends CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $ownerId */ - public function leftJoinOwner(IQueryBuilder &$qb, string $ownerId = '') { + public function leftJoinOwner(IQueryBuilder $qb, string $ownerId = '') { if ($qb->getType() !== QueryBuilder::SELECT) { return; diff --git a/lib/Db/CoreRequestBuilder.php b/lib/Db/CoreRequestBuilder.php index 858137d1..3e8f21ed 100644 --- a/lib/Db/CoreRequestBuilder.php +++ b/lib/Db/CoreRequestBuilder.php @@ -10,6 +10,7 @@ namespace OCA\Circles\Db; use Doctrine\DBAL\Query\QueryBuilder; +use OCA\Circles\Exceptions\GSStatusException; use OCA\Circles\Model\Member; use OCA\Circles\Service\ConfigService; use OCA\Circles\Service\MiscService; @@ -97,7 +98,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param int $id */ - protected function limitToId(IQueryBuilder &$qb, $id) { + protected function limitToId(IQueryBuilder $qb, $id) { $this->limitToDBField($qb, 'id', $id); } @@ -108,7 +109,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param int $uniqueId */ - protected function limitToUniqueId(IQueryBuilder &$qb, $uniqueId) { + protected function limitToUniqueId(IQueryBuilder $qb, $uniqueId) { $this->limitToDBField($qb, 'unique_id', $uniqueId); } @@ -119,7 +120,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param int $bookId */ - protected function limitToAddressBookId(IQueryBuilder &$qb, $bookId) { + protected function limitToAddressBookId(IQueryBuilder $qb, $bookId) { $this->limitToDBField($qb, 'contact_addressbook', (string)$bookId); } @@ -130,7 +131,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $groupName */ - protected function limitToContactGroup(IQueryBuilder &$qb, $groupName) { + protected function limitToContactGroup(IQueryBuilder $qb, $groupName) { $this->limitToDBField($qb, 'contact_groupname', $groupName); } @@ -141,7 +142,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $contactId */ - protected function limitToContactId(IQueryBuilder &$qb, $contactId) { + protected function limitToContactId(IQueryBuilder $qb, $contactId) { $this->limitToDBField($qb, 'contact_id', $contactId); } @@ -152,7 +153,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $token */ - protected function limitToToken(IQueryBuilder &$qb, $token) { + protected function limitToToken(IQueryBuilder $qb, $token) { $this->limitToDBField($qb, 'token', $token); } @@ -163,7 +164,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param $userId */ - protected function limitToUserId(IQueryBuilder &$qb, $userId) { + protected function limitToUserId(IQueryBuilder $qb, $userId) { $this->limitToDBField($qb, 'user_id', $userId); } @@ -174,7 +175,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param $owner */ - protected function limitToOwner(IQueryBuilder &$qb, $owner) { + protected function limitToOwner(IQueryBuilder $qb, $owner) { $this->limitToDBField($qb, 'owner', $owner); } @@ -185,7 +186,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $memberId */ - protected function limitToMemberId(IQueryBuilder &$qb, string $memberId) { + protected function limitToMemberId(IQueryBuilder $qb, string $memberId) { $this->limitToDBField($qb, 'member_id', $memberId); } @@ -196,7 +197,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param int $type */ - protected function limitToUserType(IQueryBuilder &$qb, $type) { + protected function limitToUserType(IQueryBuilder $qb, $type) { $this->limitToDBField($qb, 'user_type', $type); } @@ -207,7 +208,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $instance */ - protected function limitToInstance(IQueryBuilder &$qb, string $instance) { + protected function limitToInstance(IQueryBuilder $qb, string $instance) { $this->limitToDBField($qb, 'instance', $instance); } @@ -218,7 +219,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $circleUniqueId */ - protected function limitToCircleId(IQueryBuilder &$qb, $circleUniqueId) { + protected function limitToCircleId(IQueryBuilder $qb, $circleUniqueId) { $this->limitToDBField($qb, 'circle_id', $circleUniqueId); } @@ -229,7 +230,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param int $shareId */ - protected function limitToShareId(IQueryBuilder &$qb, int $shareId) { + protected function limitToShareId(IQueryBuilder $qb, int $shareId) { $this->limitToDBField($qb, 'share_id', $shareId); } @@ -240,7 +241,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $mountpoint */ - protected function limitToMountpoint(IQueryBuilder &$qb, string $mountpoint) { + protected function limitToMountpoint(IQueryBuilder $qb, string $mountpoint) { $this->limitToDBField($qb, 'share_id', $mountpoint); } @@ -250,7 +251,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $hash */ - protected function limitToMountpointHash(IQueryBuilder &$qb, string $hash) { + protected function limitToMountpointHash(IQueryBuilder $qb, string $hash) { $this->limitToDBField($qb, 'share_id', $hash); } @@ -262,7 +263,7 @@ class CoreRequestBuilder { // * @param string $circleUniqueId // * @param $length // */ -// protected function limitToShortenUniqueId(IQueryBuilder &$qb, $circleUniqueId, $length) { +// protected function limitToShortenUniqueId(IQueryBuilder $qb, $circleUniqueId, $length) { // $expr = $qb->expr(); // $pf = ($qb->getType() === QueryBuilder::SELECT) ? '`' . $this->default_select_alias . '`.' : ''; // @@ -282,7 +283,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param int $groupId */ - protected function limitToGroupId(IQueryBuilder &$qb, $groupId) { + protected function limitToGroupId(IQueryBuilder $qb, $groupId) { $this->limitToDBField($qb, 'group_id', $groupId); } @@ -293,7 +294,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $name */ - protected function limitToName(IQueryBuilder &$qb, $name) { + protected function limitToName(IQueryBuilder $qb, $name) { $this->limitToDBField($qb, 'name', $name); } @@ -304,7 +305,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $name */ - protected function limitToStatus(IQueryBuilder &$qb, $name) { + protected function limitToStatus(IQueryBuilder $qb, $name) { $this->limitToDBFieldOrGreater($qb, 'status', $name); } @@ -315,7 +316,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $type */ - protected function limitToShareType(IQueryBuilder &$qb, string $type) { + protected function limitToShareType(IQueryBuilder $qb, string $type) { $this->limitToDBField($qb, 'share_type', $type); } @@ -326,7 +327,7 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $with */ - protected function limitToShareWith(IQueryBuilder &$qb, string $with) { + protected function limitToShareWith(IQueryBuilder $qb, string $with) { $this->limitToDBField($qb, 'share_with', $with); } @@ -340,7 +341,7 @@ class CoreRequestBuilder { * @param int $level * @param string|array $pf */ - protected function limitToLevel(IQueryBuilder &$qb, $level, $pf = '') { + protected function limitToLevel(IQueryBuilder $qb, int $level, $pf = '') { $expr = $qb->expr(); if ($pf === '') { @@ -361,11 +362,12 @@ class CoreRequestBuilder { /** * @param IQueryBuilder $qb + * @param int $level * @param array $pf * * @return mixed */ - private function generateLimitToLevelMultipleTableRequest(IQueryBuilder $qb, $level, $pf) { + private function generateLimitToLevelMultipleTableRequest(IQueryBuilder $qb, int $level, $pf) { $expr = $qb->expr(); $orX = $expr->orX(); @@ -385,7 +387,7 @@ class CoreRequestBuilder { * * @param IQueryBuilder $qb */ - protected function limitToMembersAndAlmost(IQueryBuilder &$qb) { + protected function limitToMembersAndAlmost(IQueryBuilder $qb) { $expr = $qb->expr(); $pf = ($qb->getType() === QueryBuilder::SELECT) ? $this->default_select_alias . '.' : ''; @@ -404,7 +406,7 @@ class CoreRequestBuilder { * @param string $field * @param string|integer $value */ - private function limitToDBField(IQueryBuilder &$qb, $field, $value) { + private function limitToDBField(IQueryBuilder $qb, $field, $value) { $expr = $qb->expr(); $pf = ($qb->getType() === QueryBuilder::SELECT) ? $this->default_select_alias . '.' : ''; $qb->andWhere($expr->eq($pf . $field, $qb->createNamedParameter($value))); @@ -416,7 +418,7 @@ class CoreRequestBuilder { * @param string $field * @param string|integer $value */ - private function limitToDBFieldOrGreater(IQueryBuilder &$qb, $field, $value) { + private function limitToDBFieldOrGreater(IQueryBuilder $qb, $field, $value) { $expr = $qb->expr(); $pf = ($qb->getType() === QueryBuilder::SELECT) ? $this->default_select_alias . '.' : ''; $qb->andWhere($expr->gte($pf . $field, $qb->createNamedParameter($value))); @@ -453,7 +455,7 @@ class CoreRequestBuilder { * * @param IQueryBuilder $qb */ - protected function leftJoinCircle(IQueryBuilder &$qb) { + protected function leftJoinCircle(IQueryBuilder $qb) { if ($qb->getType() !== QueryBuilder::SELECT) { return; } @@ -479,6 +481,8 @@ class CoreRequestBuilder { * @param IQueryBuilder $qb * @param string $userId * @param string $field + * + * @throws GSStatusException */ protected function leftJoinNCGroupAndUser(IQueryBuilder $qb, $userId, $field) { if (!$this->configService->isLinkedGroupsAllowed()) { diff --git a/lib/Db/FederatedLinksRequest.php b/lib/Db/FederatedLinksRequest.php index e883332f..8531936d 100644 --- a/lib/Db/FederatedLinksRequest.php +++ b/lib/Db/FederatedLinksRequest.php @@ -217,9 +217,7 @@ class FederatedLinksRequest extends FederatedLinksRequestBuilder { throw new FederatedLinkDoesNotExistException($this->l10n->t('Federated link not found')); } - $entry = $this->parseLinksSelectSql($data); - - return $entry; + return $this->parseLinksSelectSql($data); } diff --git a/lib/Db/MembersRequest.php b/lib/Db/MembersRequest.php index 80c3ab39..e3e23529 100644 --- a/lib/Db/MembersRequest.php +++ b/lib/Db/MembersRequest.php @@ -31,6 +31,7 @@ namespace OCA\Circles\Db; use daita\MySmallPhpTools\Traits\TStringTools; use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Exception; +use OCA\Circles\Exceptions\GSStatusException; use OCA\Circles\Exceptions\MemberAlreadyExistsException; use OCA\Circles\Exceptions\MemberDoesNotExistException; use OCA\Circles\Model\Member; @@ -116,6 +117,7 @@ class MembersRequest extends MembersRequestBuilder { * @param bool $incGroup * * @return Member[] + * @throws GSStatusException */ public function forceGetMembers( $circleUniqueId, $level = Member::LEVEL_MEMBER, int $type = 0, $incGroup = false diff --git a/lib/Db/SharingFrameRequest.php b/lib/Db/SharingFrameRequest.php index 79a8f769..8c5e0c48 100644 --- a/lib/Db/SharingFrameRequest.php +++ b/lib/Db/SharingFrameRequest.php @@ -55,9 +55,7 @@ class SharingFrameRequest extends SharingFrameRequestBuilder { throw new SharingFrameDoesNotExistException($this->l10n->t('Sharing Frame does not exist')); } - $entry = $this->parseSharesSelectSql($data); - - return $entry; + return $this->parseSharesSelectSql($data); } @@ -120,4 +118,4 @@ class SharingFrameRequest extends SharingFrameRequestBuilder { } -}
\ No newline at end of file +} diff --git a/lib/Exceptions/ApiVersionIncompatibleException.php b/lib/Exceptions/ApiVersionIncompatibleException.php index 2a0ec03c..36234c2f 100644 --- a/lib/Exceptions/ApiVersionIncompatibleException.php +++ b/lib/Exceptions/ApiVersionIncompatibleException.php @@ -26,7 +26,9 @@ namespace OCA\Circles\Exceptions; -class ApiVersionIncompatibleException extends \Exception { +use Exception; + +class ApiVersionIncompatibleException extends Exception { } diff --git a/lib/Exceptions/BroadcasterIsNotCompatibleException.php b/lib/Exceptions/BroadcasterIsNotCompatibleException.php index 75dae6c5..ee1a5a29 100644 --- a/lib/Exceptions/BroadcasterIsNotCompatibleException.php +++ b/lib/Exceptions/BroadcasterIsNotCompatibleException.php @@ -26,7 +26,9 @@ namespace OCA\Circles\Exceptions; -class BroadcasterIsNotCompatibleException extends \Exception { +use Exception; + +class BroadcasterIsNotCompatibleException extends Exception { } diff --git a/lib/GlobalScale/GSMount/MountProvider.php b/lib/GlobalScale/GSMount/MountProvider.php index b1e38542..85b2a9a9 100644 --- a/lib/GlobalScale/GSMount/MountProvider.php +++ b/lib/GlobalScale/GSMount/MountProvider.php @@ -41,6 +41,7 @@ use OCP\Federation\ICloudIdManager; use OCP\Files\Config\IMountProvider; use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OCP\Files\Storage\IStorageFactory; use OCP\IUser; @@ -146,6 +147,9 @@ class MountProvider implements IMountProvider { /** * @param string $userId * @param GSShare $share + * + * @throws OC\User\NoUserException + * @throws NotPermittedException */ private function fixDuplicateFile(string $userId, GSShare $share) { $fs = \OC::$server->getRootFolder() diff --git a/lib/GlobalScale/MemberLevel.php b/lib/GlobalScale/MemberLevel.php index 81090a0e..5a0212bb 100644 --- a/lib/GlobalScale/MemberLevel.php +++ b/lib/GlobalScale/MemberLevel.php @@ -135,7 +135,7 @@ class MemberLevel extends AGlobalScaleEvent { * @throws MemberIsNotModeratorException * @throws ModeratorIsNotHighEnoughException */ - private function verifyMemberLevel(GSEvent $event, Circle $circle, Member &$member, int $level) { + private function verifyMemberLevel(GSEvent $event, Circle $circle, Member $member, int $level) { $member->hasToBeMember(); $member->cantBeOwner(); @@ -156,7 +156,7 @@ class MemberLevel extends AGlobalScaleEvent { * @throws MemberIsNotOwnerException * @throws MemberIsOwnerException */ - private function verifySwitchOwner(GSEvent $event, Circle $circle, Member &$member) { + private function verifySwitchOwner(GSEvent $event, Circle $circle, Member $member) { if (!$event->isForced()) { $isMod = $circle->getHigherViewer(); $this->circlesService->hasToBeOwner($isMod); diff --git a/lib/IBroadcaster.php b/lib/IBroadcaster.php index 45caa1a7..9a3e07d4 100644 --- a/lib/IBroadcaster.php +++ b/lib/IBroadcaster.php @@ -27,8 +27,6 @@ interface IBroadcaster { * * @param SharingFrame $frame * @param Circle $circle - * - * @return */ public function createShareToCircle(SharingFrame $frame, Circle $circle); @@ -38,8 +36,6 @@ interface IBroadcaster { * * @param SharingFrame $frame * @param Circle $circle - * - * @return */ public function editShareToCircle(SharingFrame $frame, Circle $circle); @@ -49,8 +45,6 @@ interface IBroadcaster { * * @param SharingFrame $frame * @param Circle $circle - * - * @return */ public function deleteShareToCircle(SharingFrame $frame, Circle $circle); @@ -60,8 +54,6 @@ interface IBroadcaster { * * @param SharingFrame $frame * @param Member $member - * - * @return */ public function createShareToMember(SharingFrame $frame, Member $member); @@ -71,8 +63,6 @@ interface IBroadcaster { * * @param SharingFrame $frame * @param Member $member - * - * @return */ public function editShareToMember(SharingFrame $frame, Member $member); @@ -82,9 +72,7 @@ interface IBroadcaster { * * @param SharingFrame $frame * @param Member $member - * - * @return */ public function deleteShareToMember(SharingFrame $frame, Member $member); -}
\ No newline at end of file +} diff --git a/lib/Model/BaseMember.php b/lib/Model/BaseMember.php index 66a0eeb3..67c72240 100644 --- a/lib/Model/BaseMember.php +++ b/lib/Model/BaseMember.php @@ -26,11 +26,13 @@ namespace OCA\Circles\Model; +use JsonSerializable; +use OC; use OCA\Circles\AppInfo\Application; use OCA\Circles\Service\MiscService; use OCP\IL10N; -class BaseMember implements \JsonSerializable { +class BaseMember implements JsonSerializable { const LEVEL_NONE = 0; const LEVEL_MEMBER = 1; @@ -53,9 +55,6 @@ class BaseMember implements \JsonSerializable { /** @var string */ private $circleUniqueId; - /** @var string */ - private $circleContactGroupName; - /** @var IL10N */ protected $l10n; @@ -109,7 +108,7 @@ class BaseMember implements \JsonSerializable { * @param int $type */ public function __construct($userId = '', $type = 0, $circleUniqueId = '') { - $this->l10n = \OC::$server->getL10N(Application::APP_NAME); + $this->l10n = OC::$server->getL10N(Application::APP_NAME); $this->setType($type); $this->setUserId($userId); @@ -139,25 +138,6 @@ class BaseMember implements \JsonSerializable { /** - * @param string $circleContactGroupName - * - * @return $this - */ - public function setCircleContactGroupName($circleContactGroupName): self { - $this->circleContactGroupName = $circleContactGroupName; - - return $this; - } - - /** - * @return string - */ - public function getCircleContactGroupName(): string { - return $this->circleUniqueId; - } - - - /** * @return int */ public function getType() { diff --git a/lib/Model/SharingFrame.php b/lib/Model/SharingFrame.php index 904c8913..b5d93cb9 100644 --- a/lib/Model/SharingFrame.php +++ b/lib/Model/SharingFrame.php @@ -331,9 +331,7 @@ class SharingFrame implements \JsonSerializable { * @return Circle */ private static function getCircleFromArray($arr) { - $circle = Circle::fromArray(MiscService::get($arr, 'circle', null)); - - return $circle; + return Circle::fromArray(MiscService::get($arr, 'circle', null)); } } diff --git a/lib/Service/CirclesService.php b/lib/Service/CirclesService.php index 14123064..f06bde2e 100644 --- a/lib/Service/CirclesService.php +++ b/lib/Service/CirclesService.php @@ -43,7 +43,7 @@ use OCA\Circles\Exceptions\CircleDoesNotExistException; use OCA\Circles\Exceptions\CircleTypeDisabledException; use OCA\Circles\Exceptions\ConfigNoCircleAvailableException; use OCA\Circles\Exceptions\FederatedCircleNotAllowedException; -use OCA\Circles\Exceptions\MemberDoesNotExistException; +use OCA\Circles\Exceptions\GSStatusException; use OCA\Circles\Exceptions\MemberIsNotOwnerException; use OCA\Circles\Exceptions\MembersLimitException; use OCA\Circles\Model\Circle; @@ -282,7 +282,7 @@ class CirclesService { * * @throws Exception */ - private function detailsCircleMembers(Circle &$circle) { + private function detailsCircleMembers(Circle $circle) { if ($this->viewerIsAdmin()) { $members = $this->membersRequest->forceGetMembers($circle->getUniqueId(), 0); } else { @@ -301,9 +301,9 @@ class CirclesService { * * @param Circle $circle * - * @throws MemberDoesNotExistException + * @throws GSStatusException */ - private function detailsCircleLinkedGroups(Circle &$circle) { + private function detailsCircleLinkedGroups(Circle $circle) { $groups = []; if ($this->configService->isLinkedGroupsAllowed()) { $groups = @@ -321,7 +321,7 @@ class CirclesService { * * @param Circle $circle */ - private function detailsCircleFederatedCircles(Circle &$circle) { + private function detailsCircleFederatedCircles(Circle $circle) { $links = []; try { @@ -529,17 +529,16 @@ class CirclesService { * @param int $offset * * @return array + * @throws GSStatusException */ public function getFilesForCircles($circleUniqueIds, $limit = -1, $offset = 0) { if (!is_array($circleUniqueIds)) { $circleUniqueIds = [$circleUniqueIds]; } - $objectIds = $this->circleProviderRequest->getFilesForCircles( + return $this->circleProviderRequest->getFilesForCircles( $this->userId, $circleUniqueIds, $limit, $offset ); - - return $objectIds; } diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 025f6bf8..746627c1 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -467,6 +467,7 @@ class ConfigService { /** * @param string $type * + * @return array|bool|mixed * @throws GSStatusException */ public function getGSStatus(string $type = '') { diff --git a/lib/Service/EventsService.php b/lib/Service/EventsService.php index 0764d3c8..8934e9f7 100644 --- a/lib/Service/EventsService.php +++ b/lib/Service/EventsService.php @@ -936,7 +936,7 @@ class EventsService { * @param string $context * @param array $arguments */ - private function dispatch($context, $arguments) { + private function dispatch(string $context, $arguments) { $this->eventDispatcher->dispatch($context, new GenericEvent(null, $arguments)); } diff --git a/lib/Service/FederatedLinkCreationService.php b/lib/Service/FederatedLinkCreationService.php index 5c359fc7..fe145edc 100644 --- a/lib/Service/FederatedLinkCreationService.php +++ b/lib/Service/FederatedLinkCreationService.php @@ -164,7 +164,7 @@ class FederatedLinkCreationService { * * @throws Exception */ - public function requestedLinkFromRemoteCircle(Circle $circle, FederatedLink &$link) { + public function requestedLinkFromRemoteCircle(Circle $circle, FederatedLink $link) { try { $this->checkLinkRequestValidity($circle, $link); @@ -253,6 +253,7 @@ class FederatedLinkCreationService { * @param $remote * * @return FederatedLink + * @throws Exception */ private function generateNewLink($circleUniqueId, $remote) { @@ -317,7 +318,7 @@ class FederatedLinkCreationService { * * @throws Exception */ - private function eventOnRequestLink(Circle $circle, FederatedLink &$link, $status, $reason) { + private function eventOnRequestLink(Circle $circle, FederatedLink $link, $status, $reason) { switch ($status) { case FederatedLink::STATUS_LINK_UP: @@ -365,4 +366,4 @@ class FederatedLinkCreationService { } -}
\ No newline at end of file +} diff --git a/lib/Service/FederatedLinkService.php b/lib/Service/FederatedLinkService.php index a1d1c27b..c092bbe5 100644 --- a/lib/Service/FederatedLinkService.php +++ b/lib/Service/FederatedLinkService.php @@ -322,7 +322,7 @@ class FederatedLinkService { * @return bool * @throws Exception */ - private function updateLinkRemote(FederatedLink &$link) { + private function updateLinkRemote(FederatedLink $link) { try { $client = $this->clientService->newClient(); @@ -378,7 +378,7 @@ class FederatedLinkService { * @param Circle $circle * @param FederatedLink $link */ - private function checkUpdateLinkFromRemoteLinkRequestSent(Circle $circle, FederatedLink &$link) { + private function checkUpdateLinkFromRemoteLinkRequestSent(Circle $circle, FederatedLink $link) { if ($link->getStatus() !== FederatedLink::STATUS_REQUEST_SENT) { return; @@ -393,7 +393,7 @@ class FederatedLinkService { * @param Circle $circle * @param FederatedLink $link */ - private function checkUpdateLinkFromRemoteLinkRequested(Circle $circle, FederatedLink &$link) { + private function checkUpdateLinkFromRemoteLinkRequested(Circle $circle, FederatedLink $link) { if ($link->getStatus() !== FederatedLink::STATUS_LINK_REQUESTED) { return; @@ -408,7 +408,7 @@ class FederatedLinkService { * @param Circle $circle * @param FederatedLink $link */ - private function checkUpdateLinkFromRemoteLinkDown(Circle $circle, FederatedLink &$link) { + private function checkUpdateLinkFromRemoteLinkDown(Circle $circle, FederatedLink $link) { if ($link->getStatus() < FederatedLink::STATUS_LINK_DOWN) { return; @@ -441,4 +441,4 @@ class FederatedLinkService { } -}
\ No newline at end of file +} diff --git a/lib/Service/GlobalScaleService.php b/lib/Service/GlobalScaleService.php index 5792c719..bfb1cab8 100644 --- a/lib/Service/GlobalScaleService.php +++ b/lib/Service/GlobalScaleService.php @@ -216,6 +216,7 @@ class GlobalScaleService { * @param bool $all * * @return array + * @throws NoUserException */ public function getInstances(bool $all = false): array { /** @var string $lookup */ @@ -226,10 +227,7 @@ class GlobalScaleService { $request->setVerifyPeer(false); } - try { - $user = $this->getRandomUser(); - } catch (NoUserException $e) { - } + $user = $this->getRandomUser(); $data = $this->signer->sign('lookupserver', ['federationId' => $user->getCloudId()], $user); $request->setData($data); $request->setAddressFromUrl($lookup); diff --git a/lib/Service/GroupsService.php b/lib/Service/GroupsService.php index 3cb41515..3ef80a2e 100644 --- a/lib/Service/GroupsService.php +++ b/lib/Service/GroupsService.php @@ -247,7 +247,7 @@ class GroupsService { * * @throws \Exception */ - private function editGroupLevel(Circle $circle, Member &$group, $level) { + private function editGroupLevel(Circle $circle, Member $group, $level) { try { $isMod = $circle->getHigherViewer(); $this->circlesService->hasToBeAdmin($isMod); diff --git a/lib/Service/MembersService.php b/lib/Service/MembersService.php index 3c6bead6..45d1944b 100644 --- a/lib/Service/MembersService.php +++ b/lib/Service/MembersService.php @@ -110,6 +110,7 @@ class MembersService { * @param TokensRequest $tokensRequest * @param CirclesService $circlesService * @param EventsService $eventsService + * @param GSUpstreamService $gsUpstreamService * @param FileSharingBroadcaster $fileSharingBroadcaster * @param MiscService $miscService */ @@ -246,7 +247,7 @@ class MembersService { * @throws CircleTypeNotValidException * @throws MemberCantJoinCircleException */ - public function addMemberBasedOnItsType(Circle $circle, Member &$member) { + public function addMemberBasedOnItsType(Circle $circle, Member $member) { $this->addLocalMember($circle, $member); $this->addEmailAddress($member); $this->addContact($member); @@ -355,13 +356,12 @@ class MembersService { /** * Verify if a mail have a valid format. * - * @param $ident - * @param $type + * @param string $ident + * @param int $type * * @throws EmailAccountInvalidFormatException */ - private function verifyIdentEmailAddress(&$ident, $type) { - + private function verifyIdentEmailAddress(string $ident, int $type) { if ($type !== Member::TYPE_MAIL) { return; } @@ -418,7 +418,6 @@ class MembersService { * @throws Exception */ private function addGroupMembers(Circle $circle, $groupId): array { - $group = OC::$server->getGroupManager() ->get($groupId); if ($group === null) { diff --git a/lib/Service/SharingFrameService.php b/lib/Service/SharingFrameService.php index 5a32be13..27485242 100644 --- a/lib/Service/SharingFrameService.php +++ b/lib/Service/SharingFrameService.php @@ -34,6 +34,7 @@ use OCA\Circles\Db\CirclesRequest; use OCA\Circles\Db\FederatedLinksRequest; use OCA\Circles\Db\SharingFrameRequest; use OCA\Circles\Exceptions\CircleDoesNotExistException; +use OCA\Circles\Exceptions\ConfigNoCircleAvailableException; use OCA\Circles\Exceptions\MemberDoesNotExistException; use OCA\Circles\Exceptions\PayloadDeliveryException; use OCA\Circles\Exceptions\SharingFrameAlreadyDeliveredException; @@ -216,6 +217,9 @@ class SharingFrameService { * @param $viewerId * * @return SharingFrame[] + * @throws CircleDoesNotExistException + * @throws MemberDoesNotExistException + * @throws ConfigNoCircleAvailableException */ public function forceGetFrameFromCircle($circleUniqueId, $viewerId) { @@ -263,7 +267,7 @@ class SharingFrameService { * @return bool * @throws Exception */ - public function receiveFrame($token, $uniqueId, SharingFrame &$frame) { + public function receiveFrame($token, $uniqueId, SharingFrame $frame) { try { $link = $this->federatedLinksRequest->getLinkFromToken((string)$token, (string)$uniqueId); $circle = $this->circlesRequest->forceGetCircle($link->getCircleId()); diff --git a/lib/ShareByCircleProvider.php b/lib/ShareByCircleProvider.php index 0f7cface..ded76e16 100644 --- a/lib/ShareByCircleProvider.php +++ b/lib/ShareByCircleProvider.php @@ -57,6 +57,7 @@ use OCA\Circles\Service\TimezoneService; use OCP\AppFramework\QueryException; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\Files\Folder; +use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; @@ -358,6 +359,7 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi * @param IShare $share * * @return int + * @throws NotFoundException */ private function createShareChild($userId, $share) { $qb = $this->getBaseInsertSql($share); @@ -407,6 +409,9 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi * @param int $offset * * @return Share[] + * @throws NoUserException + * @throws NotFoundException + * @throws InvalidPathException */ public function getSharesBy($userId, $shareType, $node, $reShares, $limit, $offset) { $qb = $this->getBaseSelectSql(); @@ -489,6 +494,8 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi * @param Node $path * * @return IShare[]|null + * @throws InvalidPathException + * @throws NotFoundException */ public function getSharesByPath(Node $path) { $qb = $this->getBaseSelectSql(); @@ -516,11 +523,12 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi * @param int $offset * * @return IShare[] + * @throws Exceptions\GSStatusException + * @throws InvalidPathException + * @throws NotFoundException */ public function getSharedWith($userId, $shareType, $node, $limit, $offset) { - $shares = $this->getSharedWithCircleMembers($userId, $shareType, $node, $limit, $offset); - - return $shares; + return $this->getSharedWithCircleMembers($userId, $shareType, $node, $limit, $offset); } @@ -532,6 +540,9 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi * @param int $offset * * @return IShare[] + * @throws Exceptions\GSStatusException + * @throws InvalidPathException + * @throws NotFoundException */ private function getSharedWithCircleMembers($userId, $shareType, $node, $limit, $offset) { @@ -722,6 +733,7 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi * @param array $data * * @return IShare + * @throws IllegalIDChangeException */ private function createShareObject($data) { $share = new Share($this->rootFolder, $this->userManager); @@ -752,7 +764,7 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi * @param IShare $share * @param $data */ - private function assignShareObjectPropertiesFromParent(IShare &$share, $data) { + private function assignShareObjectPropertiesFromParent(IShare $share, $data) { if (isset($data['f_permissions'])) { $entryData = $data; $entryData['permissions'] = $entryData['f_permissions']; @@ -770,8 +782,10 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi /** * @param IShare $share * @param $data + * + * @throws NoUserException */ - private function assignShareObjectSharesProperties(IShare &$share, $data) { + private function assignShareObjectSharesProperties(IShare $share, $data) { $shareTime = new \DateTime(); $shareTime->setTimestamp((int)$data['stime']); @@ -804,6 +818,7 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi * @param IShare $share * * @return Exception + * @throws NotFoundException */ private function errorShareAlreadyExist($share) { $share_src = $share->getNode() @@ -827,6 +842,8 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi * get revived later) * * @return array + * @throws InvalidPathException + * @throws NotFoundException * @see IManager::getAccessList() for sample docs * * @since 12 @@ -970,9 +987,10 @@ class ShareByCircleProvider extends CircleProviderRequest implements IShareProvi $cursor = $qb->execute(); while ($data = $cursor->fetch()) { - $share = $this->createShareObject($data); - - yield $share; + try { + yield $this->createShareObject($data); + } catch (IllegalIDChangeException $e) { + }; } $cursor->closeCursor(); } |