Skip to content

Commit

Permalink
Merge pull request #3022 from nextcloud/ref/psalm
Browse files Browse the repository at this point in the history
Code maintenence
  • Loading branch information
dartcafe authored Aug 13, 2023
2 parents 7fb5102 + 3484143 commit ae4bcdf
Show file tree
Hide file tree
Showing 24 changed files with 14 additions and 352 deletions.
7 changes: 0 additions & 7 deletions lib/Cron/GroupDeletedJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ protected function run($argument) {
'group' => $group
]);

$replacementName = 'deleted_' . $this->secureRandom->generate(
8,
ISecureRandom::CHAR_DIGITS .
ISecureRandom::CHAR_LOWER .
ISecureRandom::CHAR_UPPER
);

$this->shareMapper->deleteByIdAndType($group, Share::TYPE_GROUP);
}
}
4 changes: 0 additions & 4 deletions lib/Db/Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,6 @@ public function getExpired(): bool {
);
}

public function getUri(): string {
return self::URI_PREFIX . $this->getId();
}

public function getVoteUrl() : string {
return $this->urlGenerator->linkToRouteAbsolute(
AppConstants::APP_ID . '.page.vote',
Expand Down
13 changes: 1 addition & 12 deletions lib/Db/PollMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,6 @@ public function find(int $id): Poll {
return $this->findEntity($qb);
}

/**
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @return Poll[]
*/
public function findAll(): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName());
return $this->findEntities($qb);
}

/**
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @return Poll[]
Expand Down Expand Up @@ -110,7 +99,7 @@ public function findOwner(string $userId): array {
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @return Poll[]
*/
public function search(string $userId, ISearchQuery $query): array {
public function search(ISearchQuery $query): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
Expand Down
48 changes: 0 additions & 48 deletions lib/Db/ShareMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,6 @@ public function __construct(IDBConnection $db) {
parent::__construct($db, Share::TABLE, Share::class);
}

/**
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @return Share[]
* @psalm-return array<array-key, Share>
*/
public function findAll(): array {
$qb = $this->db->getQueryBuilder();

$qb->select('*')
->from($this->getTableName());

return $this->findEntities($qb);
}


/**
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @return Share[]
Expand Down Expand Up @@ -145,25 +130,6 @@ public function findByToken(string $token): Share {
}
}

public function deleteByPoll(int $pollId): void {
$qb = $this->db->getQueryBuilder();

$qb->delete($this->getTableName())
->where(
$qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT))
);

$qb->executeStatement();
}

public function deleteByUserId(string $userId): void {
$query = $this->db->getQueryBuilder();
$query->delete($this->getTableName())
->where('user_id = :userId')
->setParameter('userId', $userId);
$query->executeStatement();
}

/**
* @return void
*/
Expand All @@ -176,18 +142,4 @@ public function deleteByIdAndType(string $id, string $type): void {
->setParameter('type', $type);
$query->executeStatement();
}

/**
* @return void
*/
public function remove(int $shareId): void {
$qb = $this->db->getQueryBuilder();

$qb->delete($this->getTableName())
->where(
$qb->expr()->eq('id', $qb->createNamedParameter($shareId, IQueryBuilder::PARAM_INT))
);

$qb->executeStatement();
}
}
15 changes: 0 additions & 15 deletions lib/Db/SubscriptionMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,6 @@ public function __construct(IDBConnection $db) {
parent::__construct($db, Subscription::TABLE, Subscription::class);
}

/**
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
* @return Subscription[]
* @psalm-return array<array-key, Subscription>
*/
public function findAll(): array {
$qb = $this->db->getQueryBuilder();

$qb->select('*')
->from($this->getTableName());

return $this->findEntities($qb);
}

/**
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
Expand Down
14 changes: 0 additions & 14 deletions lib/Db/VoteMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,6 @@ public function findParticipantsVotes(int $pollId, string $userId): array {
return $this->findEntities($qb);
}

public function deleteById(int $voteId): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
->where($qb->expr()->eq('id', $qb->createNamedParameter($voteId, IQueryBuilder::PARAM_INT)))
->executeStatement();
}

public function deleteByPollAndUserId(int $pollId, string $userId): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
Expand All @@ -151,13 +144,6 @@ public function deleteByPollAndUserId(int $pollId, string $userId): void {
->executeStatement();
}

public function deleteByPoll(int $pollId): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
->where($qb->expr()->eq('poll_id', $qb->createNamedParameter($pollId, IQueryBuilder::PARAM_INT)))
->executeStatement();
}

/**
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @return Vote[]
Expand Down
13 changes: 0 additions & 13 deletions lib/Event/BaseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use OCA\Polls\Db\Vote;
use OCA\Polls\Helper\Container;
use OCA\Polls\Service\UserService;
use OCP\AppFramework\Db\Entity;
use OCP\EventDispatcher\Event;
use OCP\IUserSession;

Expand Down Expand Up @@ -59,18 +58,10 @@ public function __construct(
];
}

public function getEventObject(): Entity {
return $this->eventObject;
}

public function getPollId(): int {
return $this->eventObject->getPollId();
}

public function getPollUrl(): string {
return $this->poll->getVoteUrl();
}

public function getPollTitle(): string {
return $this->poll->getTitle();
}
Expand All @@ -79,10 +70,6 @@ public function getPollOwner(): string {
return $this->poll->getOwner();
}

public function getPoll(): Poll {
return $this->poll;
}

public function getActor(): string {
return $this->userSession->getUser()?->getUID() ?? $this->eventObject->getUserId();
}
Expand Down
4 changes: 0 additions & 4 deletions lib/Event/CommentEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,4 @@ public function __construct(
'name' => $comment->getComment(),
];
}

public function getComment(): Comment {
return $this->comment;
}
}
4 changes: 0 additions & 4 deletions lib/Event/OptionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,4 @@ public function __construct(
'name' => $this->option->getPollOptionText(),
];
}

public function getOption(): Option {
return $this->option;
}
}
4 changes: 0 additions & 4 deletions lib/Event/ShareEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ public function __construct(Share $share) {
$this->activitySubjectParams['sharee'] = $this->getSharee()->getRichObjectString();
}

public function getShare(): Share {
return $this->share;
}

protected function getSharee() : UserBase {
return $this->userService->getUserFromShare($this->share);
}
Expand Down
4 changes: 0 additions & 4 deletions lib/Event/VoteEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,4 @@ public function __construct(
$this->activityObjectType = 'poll';
$this->vote = $vote;
}

public function getVote(): Vote {
return $this->vote;
}
}
34 changes: 0 additions & 34 deletions lib/Exceptions/BadRequestException.php

This file was deleted.

34 changes: 0 additions & 34 deletions lib/Exceptions/ContactGroupNotFound.php

This file was deleted.

34 changes: 0 additions & 34 deletions lib/Exceptions/MultipleContactsFound.php

This file was deleted.

48 changes: 0 additions & 48 deletions lib/Helper/Trace.php

This file was deleted.

Loading

0 comments on commit ae4bcdf

Please sign in to comment.