Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2021-05-08 23:13:52 +0300
committerdartcafe <github@dartcafe.de>2021-05-08 23:13:52 +0300
commit6d0058ca1eb0ef936b75cae2d7339887716b4bea (patch)
treebf6040c329952746cb10f2ea590291bf855afc0d /lib
parentcdeb5c761029577544d23df6e70e6b03a5594118 (diff)
use psalm for static analysis
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/AppInfo/Application.php36
-rw-r--r--lib/AppInfo/Application19.php48
-rw-r--r--lib/AppInfo/Application20.php60
-rw-r--r--lib/Controller/AdminController.php4
-rw-r--r--lib/Controller/CommentApiController.php6
-rw-r--r--lib/Controller/CommentController.php6
-rw-r--r--lib/Controller/OptionApiController.php12
-rw-r--r--lib/Controller/OptionController.php18
-rw-r--r--lib/Controller/PageController.php2
-rw-r--r--lib/Controller/PollApiController.php14
-rw-r--r--lib/Controller/PollController.php12
-rw-r--r--lib/Controller/PreferencesController.php8
-rw-r--r--lib/Controller/ShareApiController.php10
-rw-r--r--lib/Controller/ShareController.php14
-rw-r--r--lib/Controller/SubscriptionApiController.php6
-rw-r--r--lib/Controller/SubscriptionController.php6
-rw-r--r--lib/Controller/SystemController.php2
-rw-r--r--lib/Controller/VoteApiController.php4
-rw-r--r--lib/Controller/VoteController.php6
-rw-r--r--lib/Cron/JanitorCron.php3
-rw-r--r--lib/Cron/NotificationCron.php3
-rw-r--r--lib/Cron/UserDeletedJob.php3
-rw-r--r--lib/Db/Comment.php18
-rw-r--r--lib/Db/CommentMapper.php6
-rw-r--r--lib/Db/Log.php20
-rw-r--r--lib/Db/LogMapper.php6
-rw-r--r--lib/Db/Option.php40
-rw-r--r--lib/Db/OptionMapper.php8
-rw-r--r--lib/Db/Poll.php68
-rw-r--r--lib/Db/PollMapper.php2
-rw-r--r--lib/Db/Preferences.php8
-rw-r--r--lib/Db/PreferencesMapper.php5
-rw-r--r--lib/Db/Share.php24
-rw-r--r--lib/Db/ShareMapper.php6
-rw-r--r--lib/Db/Subscription.php8
-rw-r--r--lib/Db/SubscriptionMapper.php6
-rw-r--r--lib/Db/Vote.php20
-rw-r--r--lib/Db/VoteMapper.php6
-rw-r--r--lib/Db/Watch.php17
-rw-r--r--lib/Db/WatchMapper.php2
-rw-r--r--lib/Exceptions/BadRequestException.php2
-rw-r--r--lib/Exceptions/CirclesNotEnabledException.php2
-rw-r--r--lib/Exceptions/ContactGroupNotFound.php2
-rw-r--r--lib/Exceptions/ContactsNotEnabledExceptions.php2
-rw-r--r--lib/Exceptions/DuplicateEntryException.php2
-rw-r--r--lib/Exceptions/EmptyTitleException.php2
-rw-r--r--lib/Exceptions/Exception.php4
-rw-r--r--lib/Exceptions/InvalidAccessException.php2
-rw-r--r--lib/Exceptions/InvalidEmailAddress.php2
-rw-r--r--lib/Exceptions/InvalidOptionPropertyException.php32
-rw-r--r--lib/Exceptions/InvalidPollTypeException.php2
-rw-r--r--lib/Exceptions/InvalidShareTypeException.php2
-rw-r--r--lib/Exceptions/InvalidShowResultsException.php2
-rw-r--r--lib/Exceptions/InvalidUsernameException.php2
-rw-r--r--lib/Exceptions/MultipleContactsFound.php2
-rw-r--r--lib/Exceptions/NoUpdatesException.php2
-rw-r--r--lib/Exceptions/NotAuthorizedException.php2
-rw-r--r--lib/Exceptions/NotFoundException.php4
-rw-r--r--lib/Exceptions/ShareAlreadyExistsException.php2
-rw-r--r--lib/Exceptions/TooShortException.php2
-rw-r--r--lib/Exceptions/VoteLimitExceededException.php2
-rw-r--r--lib/Helper/Trace.php2
-rw-r--r--lib/Listener/UserDeletedListener.php8
-rw-r--r--lib/Migration/CreateIndices.php7
-rw-r--r--lib/Migration/DeleteDuplicates.php2
-rw-r--r--lib/Migration/RemoveIndices.php15
-rw-r--r--lib/Migration/Version0009Date20181125061900.php4
-rw-r--r--lib/Migration/Version0010Date20191227063812.php6
-rw-r--r--lib/Model/Acl.php2
-rw-r--r--lib/Model/CalendarEvent.php27
-rw-r--r--lib/Model/Circle.php8
-rw-r--r--lib/Model/Contact.php4
-rw-r--r--lib/Model/ContactGroup.php4
-rw-r--r--lib/Model/Email.php4
-rw-r--r--lib/Model/GenericUser.php8
-rw-r--r--lib/Model/Group.php2
-rw-r--r--lib/Model/User.php2
-rw-r--r--lib/Model/UserGroupClass.php18
-rw-r--r--lib/Service/CalendarService.php10
-rw-r--r--lib/Service/MailService.php6
-rw-r--r--lib/Service/NotificationService.php4
-rw-r--r--lib/Service/OptionService.php13
-rw-r--r--lib/Service/PollService.php2
-rw-r--r--lib/Service/PreferencesService.php4
-rw-r--r--lib/Service/ShareService.php2
-rw-r--r--lib/Service/SystemService.php3
86 files changed, 396 insertions, 400 deletions
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index 8fa3b033..1c2793ab 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -23,10 +23,38 @@
namespace OCA\Polls\AppInfo;
-if (\OCP\Util::getVersion()[0] >= 20) {
- class Application extends Application20 {
+use Closure;
+use OCP\AppFramework\App;
+use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\AppFramework\Bootstrap\IBootstrap;
+use OCP\AppFramework\Bootstrap\IRegistrationContext;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Notification\IManager as NotificationManager;
+use OCP\User\Events\UserDeletedEvent;
+use OCA\Polls\Notification\Notifier;
+use OCA\Polls\Listener\UserDeletedListener;
+
+class Application extends App implements IBootstrap {
+ public const APP_ID = 'polls';
+
+ public function __construct(array $urlParams = []) {
+ parent::__construct(self::APP_ID, $urlParams);
}
-} else {
- class Application extends Application19 {
+
+ public function boot(IBootContext $context): void {
+ $context->injectFn(Closure::fromCallable([$this, 'registerNotifications']));
+ $context->injectFn(Closure::fromCallable([$this, 'registerUserDeletedListener']));
+ }
+
+ public function register(IRegistrationContext $context): void {
+ }
+
+ public function registerNotifications(NotificationManager $notificationManager): void {
+ $notificationManager->registerNotifierService(Notifier::class);
+ }
+
+ public function registerUserDeletedListener(): void {
+ $eventDispatcher = $this->getContainer()->query(IEventDispatcher::class);
+ $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedListener::class);
}
}
diff --git a/lib/AppInfo/Application19.php b/lib/AppInfo/Application19.php
deleted file mode 100644
index b0da1168..00000000
--- a/lib/AppInfo/Application19.php
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCA\Polls\AppInfo;
-
-use OCP\AppFramework\App;
-use OCP\EventDispatcher\IEventDispatcher;
-use OCP\User\Events\UserDeletedEvent;
-use OCA\Polls\Notification\Notifier;
-use OCA\Polls\Listener\UserDeletedListener;
-
-class Application19 extends App {
- public function __construct(array $urlParams = []) {
- parent::__construct('polls', $urlParams);
- $this->registerNotifications();
- $this->registerUserDeletedListener();
- }
-
- public function registerNotifications(): void {
- $notificationManager = \OC::$server->getNotificationManager();
- $notificationManager->registerNotifierService(Notifier::class);
- }
-
- public function registerUserDeletedListener(): void {
- $eventDispatcher = $this->getContainer()->query(IEventDispatcher::class);
- $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedListener::class);
- }
-}
diff --git a/lib/AppInfo/Application20.php b/lib/AppInfo/Application20.php
deleted file mode 100644
index 0585c3f9..00000000
--- a/lib/AppInfo/Application20.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-/**
- * @copyright Copyright (c) 2017 Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @author Vinzenz Rosenkranz <vinzenz.rosenkranz@gmail.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCA\Polls\AppInfo;
-
-use Closure;
-use OCP\AppFramework\App;
-use OCP\AppFramework\Bootstrap\IBootContext;
-use OCP\AppFramework\Bootstrap\IBootstrap;
-use OCP\AppFramework\Bootstrap\IRegistrationContext;
-use OCP\EventDispatcher\IEventDispatcher;
-use OCP\Notification\IManager as NotificationManager;
-use OCP\User\Events\UserDeletedEvent;
-use OCA\Polls\Notification\Notifier;
-use OCA\Polls\Listener\UserDeletedListener;
-
-class Application20 extends App implements IBootstrap {
- public const APP_ID = 'polls';
-
- public function __construct(array $urlParams = []) {
- parent::__construct(self::APP_ID, $urlParams);
- }
-
- public function boot(IBootContext $context): void {
- $context->injectFn(Closure::fromCallable([$this, 'registerNotifications']));
- $context->injectFn(Closure::fromCallable([$this, 'registerUserDeletedListener']));
- }
-
- public function register(IRegistrationContext $context): void {
- }
-
- public function registerNotifications(NotificationManager $notificationManager): void {
- $notificationManager->registerNotifierService(Notifier::class);
- }
-
- public function registerUserDeletedListener(): void {
- $eventDispatcher = $this->getContainer()->query(IEventDispatcher::class);
- $eventDispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedListener::class);
- }
-}
diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php
index c760b7ce..7fcf8100 100644
--- a/lib/Controller/AdminController.php
+++ b/lib/Controller/AdminController.php
@@ -87,7 +87,7 @@ class AdminController extends Controller {
/**
* Switch deleted status (move to deleted polls)
*/
- public function switchDeleted($pollId): DataResponse {
+ public function switchDeleted(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return $this->pollService->switchDeleted($pollId);
});
@@ -96,7 +96,7 @@ class AdminController extends Controller {
/**
* Delete poll
*/
- public function delete($pollId): DataResponse {
+ public function delete(int $pollId): DataResponse {
return $this->responseDeleteTolerant(function () use ($pollId) {
return $this->pollService->delete($pollId);
});
diff --git a/lib/Controller/CommentApiController.php b/lib/Controller/CommentApiController.php
index 8c94fdd6..fc2c3c35 100644
--- a/lib/Controller/CommentApiController.php
+++ b/lib/Controller/CommentApiController.php
@@ -55,7 +55,7 @@ class CommentApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function list($pollId): DataResponse {
+ public function list(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return ['comments' => $this->commentService->list($pollId)];
});
@@ -67,7 +67,7 @@ class CommentApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function add($pollId, $message): DataResponse {
+ public function add(int $pollId, string $message): DataResponse {
return $this->response(function () use ($pollId, $message) {
return ['comment' => $this->commentService->add($pollId, null, $message)];
});
@@ -79,7 +79,7 @@ class CommentApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function delete($commentId): DataResponse {
+ public function delete(int $commentId): DataResponse {
return $this->responseDeleteTolerant(function () use ($commentId) {
return ['comment' => $this->commentService->delete($commentId)];
});
diff --git a/lib/Controller/CommentController.php b/lib/Controller/CommentController.php
index 2666b155..c5031881 100644
--- a/lib/Controller/CommentController.php
+++ b/lib/Controller/CommentController.php
@@ -48,7 +48,7 @@ class CommentController extends Controller {
* Write a new comment to the db and returns the new comment as array
* @NoAdminRequired
*/
- public function list($pollId): DataResponse {
+ public function list(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return ['comments' => $this->commentService->list($pollId)];
});
@@ -58,7 +58,7 @@ class CommentController extends Controller {
* Write a new comment to the db and returns the new comment as array
* @NoAdminRequired
*/
- public function add($pollId, $message): DataResponse {
+ public function add(int $pollId, string $message): DataResponse {
return $this->response(function () use ($pollId, $message) {
return ['comment' => $this->commentService->add($pollId, null, $message)];
});
@@ -68,7 +68,7 @@ class CommentController extends Controller {
* Delete Comment
* @NoAdminRequired
*/
- public function delete($commentId): DataResponse {
+ public function delete(int $commentId): DataResponse {
return $this->responseDeleteTolerant(function () use ($commentId) {
return ['comment' => $this->commentService->delete($commentId)];
});
diff --git a/lib/Controller/OptionApiController.php b/lib/Controller/OptionApiController.php
index 3201b177..a581d4fe 100644
--- a/lib/Controller/OptionApiController.php
+++ b/lib/Controller/OptionApiController.php
@@ -55,7 +55,7 @@ class OptionApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function list($pollId): DataResponse {
+ public function list(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return ['options' => $this->optionService->list($pollId)];
});
@@ -67,7 +67,7 @@ class OptionApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function add($pollId, $timestamp = 0, $pollOptionText = ''): DataResponse {
+ public function add(int $pollId, int $timestamp = 0, string $pollOptionText = ''): DataResponse {
return $this->responseCreate(function () use ($pollId, $timestamp, $pollOptionText) {
return ['option' => $this->optionService->add($pollId, $timestamp, $pollOptionText)];
});
@@ -80,7 +80,7 @@ class OptionApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function update($optionId, $timestamp = 0, $pollOptionText = ''): DataResponse {
+ public function update(int $optionId, int $timestamp = 0, string $pollOptionText = ''): DataResponse {
return $this->response(function () use ($optionId, $timestamp, $pollOptionText) {
return ['option' => $this->optionService->update($optionId, $timestamp, $pollOptionText)];
});
@@ -92,7 +92,7 @@ class OptionApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function delete($optionId): DataResponse {
+ public function delete(int $optionId): DataResponse {
return $this->responseDeleteTolerant(function () use ($optionId) {
return ['option' => $this->optionService->delete($optionId)];
});
@@ -104,7 +104,7 @@ class OptionApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function confirm($optionId): DataResponse {
+ public function confirm(int $optionId): DataResponse {
return $this->response(function () use ($optionId) {
return ['option' => $this->optionService->confirm($optionId)];
});
@@ -116,7 +116,7 @@ class OptionApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function setOrder($optionId, $order): DataResponse {
+ public function setOrder(int $optionId, int $order): DataResponse {
return $this->response(function () use ($optionId, $order) {
return ['option' => $this->optionService->setOrder($optionId, $order)];
});
diff --git a/lib/Controller/OptionController.php b/lib/Controller/OptionController.php
index 343bdd5b..2842b539 100644
--- a/lib/Controller/OptionController.php
+++ b/lib/Controller/OptionController.php
@@ -56,7 +56,7 @@ class OptionController extends Controller {
* Get all options of given poll
* @NoAdminRequired
*/
- public function list($pollId): DataResponse {
+ public function list(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return ['options' => $this->optionService->list($pollId)];
});
@@ -66,7 +66,7 @@ class OptionController extends Controller {
* Add a new option
* @NoAdminRequired
*/
- public function add($pollId, $timestamp = 0, $pollOptionText = '', $duration = 0): DataResponse {
+ public function add(int $pollId, int $timestamp = 0, string $pollOptionText = '', int $duration = 0): DataResponse {
return $this->responseCreate(function () use ($pollId, $timestamp, $pollOptionText, $duration) {
return ['option' => $this->optionService->add($pollId, $timestamp, $pollOptionText, $duration)];
});
@@ -76,7 +76,7 @@ class OptionController extends Controller {
* Update option
* @NoAdminRequired
*/
- public function update($optionId, $timestamp, $pollOptionText, $duration): DataResponse {
+ public function update(int $optionId, int $timestamp, string $pollOptionText, int $duration): DataResponse {
return $this->response(function () use ($optionId, $timestamp, $pollOptionText, $duration) {
return ['option' => $this->optionService->update($optionId, $timestamp, $pollOptionText, $duration)];
});
@@ -86,7 +86,7 @@ class OptionController extends Controller {
* Delete option
* @NoAdminRequired
*/
- public function delete($optionId): DataResponse {
+ public function delete(int $optionId): DataResponse {
return $this->responseDeleteTolerant(function () use ($optionId) {
return ['option' => $this->optionService->delete($optionId)];
});
@@ -96,7 +96,7 @@ class OptionController extends Controller {
* Switch option confirmation
* @NoAdminRequired
*/
- public function confirm($optionId): DataResponse {
+ public function confirm(int $optionId): DataResponse {
return $this->response(function () use ($optionId) {
return ['option' => $this->optionService->confirm($optionId)];
});
@@ -106,7 +106,7 @@ class OptionController extends Controller {
* Reorder options
* @NoAdminRequired
*/
- public function reorder($pollId, $options): DataResponse {
+ public function reorder(int $pollId, array $options): DataResponse {
return $this->response(function () use ($pollId, $options) {
return ['options' => $this->optionService->reorder($pollId, $options)];
});
@@ -116,7 +116,7 @@ class OptionController extends Controller {
* Reorder options
* @NoAdminRequired
*/
- public function sequence($optionId, $step, $unit, $amount): DataResponse {
+ public function sequence(int $optionId, int $step, string $unit, int $amount): DataResponse {
return $this->response(function () use ($optionId, $step, $unit, $amount) {
return ['options' => $this->optionService->sequence($optionId, $step, $unit, $amount)];
});
@@ -126,7 +126,7 @@ class OptionController extends Controller {
* Reorder options
* @NoAdminRequired
*/
- public function shift($pollId, $step, $unit): DataResponse {
+ public function shift(int $pollId, int $step, string $unit): DataResponse {
return $this->response(function () use ($pollId, $step, $unit) {
return ['options' => $this->optionService->shift($pollId, $step, $unit)];
});
@@ -136,7 +136,7 @@ class OptionController extends Controller {
* findCalendarEvents
* @NoAdminRequired
*/
- public function findCalendarEvents($optionId): DataResponse {
+ public function findCalendarEvents(int $optionId): DataResponse {
return $this->response(function () use ($optionId) {
$option = $this->optionService->get($optionId);
$searchFrom = new DateTime();
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index b5646a50..faea3e97 100644
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -62,7 +62,7 @@ class PageController extends Controller {
* @NoAdminRequired
* @NoCSRFRequired
*/
- public function vote($id): TemplateResponse {
+ public function vote(int $id): TemplateResponse {
$this->notificationService->removeNotification($id);
return new TemplateResponse('polls', 'polls.tmpl',
['urlGenerator' => $this->urlGenerator]);
diff --git a/lib/Controller/PollApiController.php b/lib/Controller/PollApiController.php
index eac7575b..1f7c02dd 100644
--- a/lib/Controller/PollApiController.php
+++ b/lib/Controller/PollApiController.php
@@ -69,7 +69,7 @@
* @CORS
* @NoCSRFRequired
*/
- public function get($pollId): DataResponse {
+ public function get(int $pollId): DataResponse {
try {
return new DataResponse(['poll' => $this->pollService->get($pollId)], Http::STATUS_OK);
} catch (DoesNotExistException $e) {
@@ -85,7 +85,7 @@
* @NoCSRFRequired
* @CORS
*/
- public function add($type, $title): DataResponse {
+ public function add(string $type, string $title): DataResponse {
try {
return new DataResponse(['poll' => $this->pollService->add($type, $title)], Http::STATUS_CREATED);
} catch (Exception $e) {
@@ -99,7 +99,7 @@
* @CORS
* @NoCSRFRequired
*/
- public function update($pollId, $poll): DataResponse {
+ public function update(int $pollId, array $poll): DataResponse {
try {
return new DataResponse(['poll' => $this->pollService->update($pollId, $poll)], Http::STATUS_OK);
} catch (DoesNotExistException $e) {
@@ -115,7 +115,7 @@
* @CORS
* @NoCSRFRequired
*/
- public function switchDeleted($pollId): DataResponse {
+ public function switchDeleted(int $pollId): DataResponse {
try {
return new DataResponse(['poll' => $this->pollService->switchDeleted($pollId)], Http::STATUS_OK);
} catch (DoesNotExistException $e) {
@@ -131,7 +131,7 @@
* @CORS
* @NoCSRFRequired
*/
- public function delete($pollId): DataResponse {
+ public function delete(int $pollId): DataResponse {
try {
return new DataResponse(['poll' => $this->pollService->delete($pollId)], Http::STATUS_OK);
} catch (DoesNotExistException $e) {
@@ -147,7 +147,7 @@
* @CORS
* @NoCSRFRequired
*/
- public function clone($pollId): DataResponse {
+ public function clone(int $pollId): DataResponse {
try {
return new DataResponse(['poll' => $this->pollService->clone($pollId)], Http::STATUS_CREATED);
} catch (DoesNotExistException $e) {
@@ -163,7 +163,7 @@
* @CORS
* @NoCSRFRequired
*/
- public function getParticipantsEmailAddresses($pollId): DataResponse {
+ public function getParticipantsEmailAddresses(int $pollId): DataResponse {
try {
return new DataResponse($this->pollService->getParticipantsEmailAddresses($pollId), Http::STATUS_OK);
} catch (DoesNotExistException $e) {
diff --git a/lib/Controller/PollController.php b/lib/Controller/PollController.php
index 11812a96..b25fc29c 100644
--- a/lib/Controller/PollController.php
+++ b/lib/Controller/PollController.php
@@ -94,7 +94,7 @@ class PollController extends Controller {
* @NoAdminRequired
*/
- public function add($type, $title): DataResponse {
+ public function add(string $type, string $title): DataResponse {
return $this->responseCreate(function () use ($type, $title) {
return $this->pollService->add($type, $title);
});
@@ -105,7 +105,7 @@ class PollController extends Controller {
* @NoAdminRequired
*/
- public function update($pollId, $poll): DataResponse {
+ public function update(int $pollId, array $poll): DataResponse {
return $this->response(function () use ($pollId, $poll) {
return $this->pollService->update($pollId, $poll);
});
@@ -116,7 +116,7 @@ class PollController extends Controller {
* @NoAdminRequired
*/
- public function switchDeleted($pollId): DataResponse {
+ public function switchDeleted(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return $this->pollService->switchDeleted($pollId);
});
@@ -127,7 +127,7 @@ class PollController extends Controller {
* @NoAdminRequired
*/
- public function delete($pollId): DataResponse {
+ public function delete(int $pollId): DataResponse {
return $this->responseDeleteTolerant(function () use ($pollId) {
return $this->pollService->delete($pollId);
});
@@ -137,7 +137,7 @@ class PollController extends Controller {
* Clone poll
* @NoAdminRequired
*/
- public function clone($pollId): DataResponse {
+ public function clone(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
$poll = $this->pollService->clone($pollId);
$this->optionService->clone($pollId, $poll->getId());
@@ -151,7 +151,7 @@ class PollController extends Controller {
* @NoAdminRequired
*/
- public function getParticipantsEmailAddresses($pollId): DataResponse {
+ public function getParticipantsEmailAddresses(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return $this->pollService->getParticipantsEmailAddresses($pollId);
});
diff --git a/lib/Controller/PreferencesController.php b/lib/Controller/PreferencesController.php
index 35bd7759..e6faf8c9 100644
--- a/lib/Controller/PreferencesController.php
+++ b/lib/Controller/PreferencesController.php
@@ -32,7 +32,11 @@ use OCA\Polls\Service\PreferencesService;
use OCA\Polls\Service\CalendarService;
class PreferencesController extends Controller {
+
+ /** @var PreferencesService */
private $preferencesService;
+
+ /** @var CalendarService */
private $calendarService;
use ResponseHandle;
@@ -54,7 +58,7 @@ class PreferencesController extends Controller {
* @NoCSRFRequired
*/
public function get(): DataResponse {
- return $this->response(function () {
+ return $this->response(function (): Preferences {
return $this->preferencesService->get();
});
}
@@ -63,7 +67,7 @@ class PreferencesController extends Controller {
* Write preferences
* @NoAdminRequired
*/
- public function write($settings): DataResponse {
+ public function write(string $settings): DataResponse {
if (!\OC::$server->getUserSession()->isLoggedIn()) {
return new DataResponse([], Http::STATUS_OK);
}
diff --git a/lib/Controller/ShareApiController.php b/lib/Controller/ShareApiController.php
index de3e3241..e9132596 100644
--- a/lib/Controller/ShareApiController.php
+++ b/lib/Controller/ShareApiController.php
@@ -60,7 +60,7 @@ class ShareApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function list($pollId): DataResponse {
+ public function list(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return ['shares' => $this->shareService->list($pollId)];
});
@@ -72,7 +72,7 @@ class ShareApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function get($token): DataResponse {
+ public function get(string $token): DataResponse {
return $this->response(function () use ($token) {
return ['share' => $this->shareService->get($token)];
});
@@ -84,7 +84,7 @@ class ShareApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function add($pollId, $type, $userId = ''): DataResponse {
+ public function add(int $pollId, string $type, string $userId = ''): DataResponse {
return $this->responseCreate(function () use ($pollId, $type, $userId) {
return ['share' => $this->shareService->add($pollId, $type, $userId)];
});
@@ -96,7 +96,7 @@ class ShareApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function delete($token): DataResponse {
+ public function delete(string $token): DataResponse {
return $this->responseDeleteTolerant(function () use ($token) {
return ['share' => $this->shareService->delete($token)];
});
@@ -108,7 +108,7 @@ class ShareApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function sendInvitation($token): DataResponse {
+ public function sendInvitation(string $token): DataResponse {
return $this->response(function () use ($token) {
$sentResult = $this->mailService->sendInvitation($token);
$share = $this->shareService->get($token);
diff --git a/lib/Controller/ShareController.php b/lib/Controller/ShareController.php
index 547ee6a2..4243f43e 100644
--- a/lib/Controller/ShareController.php
+++ b/lib/Controller/ShareController.php
@@ -69,7 +69,7 @@ class ShareController extends Controller {
*
* @return DataResponse
*/
- public function list($pollId): DataResponse {
+ public function list(int $pollId): DataResponse {
return $this->response(function () use ($pollId): array {
return ['shares' => $this->shareService->list($pollId)];
});
@@ -82,7 +82,7 @@ class ShareController extends Controller {
*
* @return DataResponse
*/
- public function get($token): DataResponse {
+ public function get(string $token): DataResponse {
return $this->response(function () use ($token): array {
return ['share' => $this->shareService->get($token, true)];
});
@@ -92,7 +92,7 @@ class ShareController extends Controller {
* Add share
* @NoAdminRequired
*/
- public function add(int $pollId, string $type, $userId = ''): DataResponse {
+ public function add(int $pollId, string $type, string $userId = ''): DataResponse {
return $this->responseCreate(function () use ($pollId, $type, $userId) {
return ['share' => $this->shareService->add($pollId, $type, $userId)];
});
@@ -113,7 +113,7 @@ class ShareController extends Controller {
* or update an email share with the username
* @NoAdminRequired
*/
- public function personal($token, $userName, $emailAddress = ''): DataResponse {
+ public function personal(string $token, string $userName, string $emailAddress = ''): DataResponse {
return $this->responseCreate(function () use ($token, $userName, $emailAddress) {
return ['share' => $this->shareService->personal($token, $userName, $emailAddress)];
});
@@ -124,7 +124,7 @@ class ShareController extends Controller {
* @NoAdminRequired
*/
- public function delete($token): DataResponse {
+ public function delete(string $token): DataResponse {
return $this->responseDeleteTolerant(function () use ($token) {
return ['share' => $this->shareService->delete($token)];
});
@@ -135,7 +135,7 @@ class ShareController extends Controller {
* Additionally send notification via notifications
* @NoAdminRequired
*/
- public function sendInvitation($token): DataResponse {
+ public function sendInvitation(string $token): DataResponse {
return $this->response(function () use ($token) {
return [
'share' => $this->shareService->get($token),
@@ -148,7 +148,7 @@ class ShareController extends Controller {
* resolve contact group to individual shares
* @NoAdminRequired
*/
- public function resolveGroup($token): DataResponse {
+ public function resolveGroup(string $token): DataResponse {
return $this->response(function () use ($token) {
$shares = [];
$share = $this->shareService->get($token);
diff --git a/lib/Controller/SubscriptionApiController.php b/lib/Controller/SubscriptionApiController.php
index 0b6a33f0..7a63e88e 100644
--- a/lib/Controller/SubscriptionApiController.php
+++ b/lib/Controller/SubscriptionApiController.php
@@ -59,7 +59,7 @@ class SubscriptionApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function get($pollId): DataResponse {
+ public function get(int $pollId): DataResponse {
try {
$this->subscriptionService->get($pollId, '');
return new DataResponse(['status' => 'Subscribed to poll ' . $pollId], Http::STATUS_OK);
@@ -76,7 +76,7 @@ class SubscriptionApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function subscribe($pollId): DataResponse {
+ public function subscribe(int $pollId): DataResponse {
try {
$this->subscriptionService->set($pollId, '', true);
return new DataResponse(['status' => 'Subscribed to poll ' . $pollId], Http::STATUS_OK);
@@ -91,7 +91,7 @@ class SubscriptionApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function unsubscribe($pollId): DataResponse {
+ public function unsubscribe(int $pollId): DataResponse {
try {
$this->subscriptionService->set($pollId, '', false);
return new DataResponse(['status' => 'Unsubscribed from poll ' . $pollId], Http::STATUS_OK);
diff --git a/lib/Controller/SubscriptionController.php b/lib/Controller/SubscriptionController.php
index 6496fe1b..deb640e1 100644
--- a/lib/Controller/SubscriptionController.php
+++ b/lib/Controller/SubscriptionController.php
@@ -49,7 +49,7 @@ class SubscriptionController extends Controller {
* Get subscription status
* @NoAdminRequired
*/
- public function get($pollId = 0): DataResponse {
+ public function get(int $pollId = 0): DataResponse {
return $this->response(function () use ($pollId) {
return ['subscribed' => $this->subscriptionService->get($pollId)];
});
@@ -59,7 +59,7 @@ class SubscriptionController extends Controller {
* subscribe
* @NoAdminRequired
*/
- public function subscribe($pollId): DataResponse {
+ public function subscribe(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return ['subscribed' => $this->subscriptionService->set($pollId, '', true)];
});
@@ -69,7 +69,7 @@ class SubscriptionController extends Controller {
* Unsubscribe
* @NoAdminRequired
*/
- public function unsubscribe($pollId): DataResponse {
+ public function unsubscribe(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return ['subscribed' => $this->subscriptionService->set($pollId, '', false)];
});
diff --git a/lib/Controller/SystemController.php b/lib/Controller/SystemController.php
index fad19a08..a00bdce6 100644
--- a/lib/Controller/SystemController.php
+++ b/lib/Controller/SystemController.php
@@ -49,7 +49,7 @@ class SystemController extends Controller {
* @NoAdminRequired
* $query
*/
- public function userSearch($query = ''): DataResponse {
+ public function userSearch(string $query = ''): DataResponse {
return new DataResponse(['siteusers' => $this->systemService->getSiteUsersAndGroups(
$query)], Http::STATUS_OK);
}
diff --git a/lib/Controller/VoteApiController.php b/lib/Controller/VoteApiController.php
index 03aa07ff..5c82a9d1 100644
--- a/lib/Controller/VoteApiController.php
+++ b/lib/Controller/VoteApiController.php
@@ -57,7 +57,7 @@ class VoteApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function list($pollId): DataResponse {
+ public function list(int $pollId): DataResponse {
try {
return new DataResponse(['votes' => $this->voteService->list($pollId)], Http::STATUS_OK);
} catch (DoesNotExistException $e) {
@@ -73,7 +73,7 @@ class VoteApiController extends ApiController {
* @CORS
* @NoCSRFRequired
*/
- public function set($optionId, $setTo): DataResponse {
+ public function set(int $optionId, string $setTo): DataResponse {
try {
return new DataResponse(['vote' => $this->voteService->set($optionId, $setTo)], Http::STATUS_OK);
} catch (DoesNotExistException $e) {
diff --git a/lib/Controller/VoteController.php b/lib/Controller/VoteController.php
index 9e06a6f8..057ed3e3 100644
--- a/lib/Controller/VoteController.php
+++ b/lib/Controller/VoteController.php
@@ -50,7 +50,7 @@ class VoteController extends Controller {
* @NoAdminRequired
* @NoCSRFRequired
*/
- public function list($pollId): DataResponse {
+ public function list(int $pollId): DataResponse {
return $this->response(function () use ($pollId) {
return ['votes' => $this->voteService->list($pollId)];
});
@@ -61,7 +61,7 @@ class VoteController extends Controller {
* @NoAdminRequired
* @NoCSRFRequired
*/
- public function set($optionId, $setTo): DataResponse {
+ public function set(int $optionId, string $setTo): DataResponse {
return $this->response(function () use ($optionId, $setTo) {
return ['vote' => $this->voteService->set($optionId, $setTo)];
});
@@ -71,7 +71,7 @@ class VoteController extends Controller {
* Remove user from poll
* @NoAdminRequired
*/
- public function delete($pollId, $userId): DataResponse {
+ public function delete(int $pollId, string $userId): DataResponse {
return $this->response(function () use ($pollId, $userId) {
return ['deleted' => $this->voteService->delete($pollId, $userId)];
});
diff --git a/lib/Cron/JanitorCron.php b/lib/Cron/JanitorCron.php
index ee69164e..24392440 100644
--- a/lib/Cron/JanitorCron.php
+++ b/lib/Cron/JanitorCron.php
@@ -47,6 +47,9 @@ class JanitorCron extends TimedJob {
parent::setInterval(86400); // run once a day
}
+ /**
+ * @return void
+ */
protected function run($arguments) {
$this->logMapper->deleteProcessedEntries(); // delete processed log entries
$this->logMapper->deleteOldEntries(time() - (86400 * 7)); // delete entries older than 7 days
diff --git a/lib/Cron/NotificationCron.php b/lib/Cron/NotificationCron.php
index 5851bd01..87f127f1 100644
--- a/lib/Cron/NotificationCron.php
+++ b/lib/Cron/NotificationCron.php
@@ -41,6 +41,9 @@ class NotificationCron extends TimedJob {
parent::setInterval(5); // run every 5 minutes
}
+ /**
+ * @return void
+ */
protected function run($arguments) {
$this->mailService->sendNotifications();
}
diff --git a/lib/Cron/UserDeletedJob.php b/lib/Cron/UserDeletedJob.php
index 0b66764a..7c02f854 100644
--- a/lib/Cron/UserDeletedJob.php
+++ b/lib/Cron/UserDeletedJob.php
@@ -89,6 +89,9 @@ class UserDeletedJob extends QueuedJob {
$this->logger = $logger;
}
+ /**
+ * @return void
+ */
protected function run($arguments) {
$owner = $arguments['owner'];
$this->logger->info('Deleting polls for deleted user {user}', [
diff --git a/lib/Db/Comment.php b/lib/Db/Comment.php
index e5d7b75d..23908be5 100644
--- a/lib/Db/Comment.php
+++ b/lib/Db/Comment.php
@@ -41,7 +41,7 @@ use OCP\AppFramework\Db\Entity;
* @method void setDt(string $value)
* @method string getComment()
* @method void setComment(string $value)
- * @method string getTimestamp()
+ * @method int getTimestamp()
* @method void setTimestamp(integer $value)
*/
class Comment extends Entity implements JsonSerializable {
@@ -62,20 +62,20 @@ class Comment extends Entity implements JsonSerializable {
protected $comment;
public function __construct() {
- $this->addType('pollId', 'integer');
- $this->addType('timestamp', 'integer');
+ $this->addType('pollId', 'int');
+ $this->addType('timestamp', 'int');
}
public function jsonSerialize() {
return [
- 'id' => $this->id,
- 'pollId' => $this->pollId,
- 'userId' => $this->userId,
- 'dt' => $this->dt,
+ 'id' => $this->getId(),
+ 'pollId' => $this->getPollId(),
+ 'userId' => $this->getUserId(),
+ 'dt' => $this->getDt(),
'timestamp' => $this->getTimestamp(),
- 'comment' => $this->comment,
+ 'comment' => $this->getComment(),
'isNoUser' => $this->getIsNoUser(),
- 'displayName' => $this->getDisplayName()
+ 'displayName' => $this->getDisplayName(),
];
}
diff --git a/lib/Db/CommentMapper.php b/lib/Db/CommentMapper.php
index a5c2e660..fc44d57a 100644
--- a/lib/Db/CommentMapper.php
+++ b/lib/Db/CommentMapper.php
@@ -33,7 +33,7 @@ use OCP\AppFramework\Db\QBMapper;
*/
class CommentMapper extends QBMapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_comments', '\OCA\Polls\Db\Comment');
+ parent::__construct($db, 'polls_comments', 'OCA\Polls\Db\Comment');
}
/**
@@ -72,7 +72,7 @@ class CommentMapper extends QBMapper {
/**
* @return void
*/
- public function deleteByPoll($pollId): void {
+ public function deleteByPoll(int $pollId): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
@@ -86,7 +86,7 @@ class CommentMapper extends QBMapper {
/**
* @return void
*/
- public function deleteComment($id): void {
+ public function deleteComment(int $id): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
diff --git a/lib/Db/Log.php b/lib/Db/Log.php
index 4ea5e0b2..f8bb5203 100644
--- a/lib/Db/Log.php
+++ b/lib/Db/Log.php
@@ -72,20 +72,20 @@ class Log extends Entity implements JsonSerializable {
protected $messageId;
public function __construct() {
- $this->addType('pollId', 'integer');
- $this->addType('created', 'integer');
- $this->addType('processed', 'integer');
+ $this->addType('pollId', 'int');
+ $this->addType('created', 'int');
+ $this->addType('processed', 'int');
}
public function jsonSerialize() {
return [
- 'id' => $this->id,
- 'pollId' => $this->pollId,
- 'created' => $this->created,
- 'processed' => $this->processed,
- 'userId' => $this->userId,
- 'displayName' => $this->displayName,
- 'message_id' => $this->messageId
+ 'id' => $this->getId(),
+ 'pollId' => $this->getPollId(),
+ 'created' => $this->getCreated(),
+ 'processed' => $this->getProcessed(),
+ 'userId' => $this->getUserId(),
+ 'displayName' => $this->getDisplayName(),
+ 'message_id' => $this->getMessageId(),
];
}
}
diff --git a/lib/Db/LogMapper.php b/lib/Db/LogMapper.php
index 447b8ec9..e2adcfc7 100644
--- a/lib/Db/LogMapper.php
+++ b/lib/Db/LogMapper.php
@@ -34,13 +34,13 @@ use Doctrine\DBAL\Exception\TableNotFoundException;
*/
class LogMapper extends QBMapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_log', '\OCA\Polls\Db\Log');
+ parent::__construct($db, 'polls_log', 'OCA\Polls\Db\Log');
}
/**
* @return Log
*/
- public function find($id): Log {
+ public function find(int $id): Log {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
@@ -56,7 +56,7 @@ class LogMapper extends QBMapper {
* @return Log[]
* @psalm-return array<array-key, Log>
*/
- public function findByPollId($pollId): array {
+ public function findByPollId(int $pollId): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
diff --git a/lib/Db/Option.php b/lib/Db/Option.php
index 05bdcda3..241cd536 100644
--- a/lib/Db/Option.php
+++ b/lib/Db/Option.php
@@ -99,27 +99,27 @@ class Option extends Entity implements JsonSerializable {
public $isBookedUp = false;
public function __construct() {
- $this->addType('released', 'integer');
- $this->addType('pollId', 'integer');
- $this->addType('timestamp', 'integer');
- $this->addType('order', 'integer');
- $this->addType('confirmed', 'integer');
- $this->addType('duration', 'integer');
+ $this->addType('released', 'int');
+ $this->addType('pollId', 'int');
+ $this->addType('timestamp', 'int');
+ $this->addType('order', 'int');
+ $this->addType('confirmed', 'int');
+ $this->addType('duration', 'int');
}
public function jsonSerialize() {
return [
- 'id' => $this->id,
- 'pollId' => $this->pollId,
- 'owner' => $this->owner,
+ 'id' => $this->getId(),
+ 'pollId' => $this->getPollId(),
+ 'owner' => $this->getOwner(),
'ownerDisplayName' => $this->getDisplayName(),
'ownerIsNoUser' => $this->getOwnerIsNoUser(),
- 'released' => $this->released,
- 'pollOptionText' => htmlspecialchars_decode($this->getPollOptionText()),
- 'timestamp' => $this->timestamp,
- 'order' => $this->timestamp ?? $this->order,
- 'confirmed' => $this->confirmed,
- 'duration' => $this->duration,
+ 'released' => $this->getReleased(),
+ 'pollOptionText' => $this->getPollOptionText(),
+ 'timestamp' => $this->getTimestamp(),
+ 'order' => $this->getOrder(),
+ 'confirmed' => $this->getConfirmed(),
+ 'duration' => $this->getDuration(),
'rank' => $this->rank,
'no' => $this->no,
'yes' => $this->yes,
@@ -135,9 +135,15 @@ class Option extends Entity implements JsonSerializable {
return date('c', $this->timestamp) . ' - ' . date('c', $this->timestamp + $this->duration);
} elseif ($this->timestamp && !$this->duration) {
return date('c', $this->timestamp);
- } else {
- return $this->pollOptionText;
}
+ return htmlspecialchars_decode($this->pollOptionText);
+ }
+
+ public function getOrder(): int {
+ if ($this->timestamp) {
+ return $this->timestamp;
+ }
+ return $this->order;
}
private function getDisplayName(): ?string {
diff --git a/lib/Db/OptionMapper.php b/lib/Db/OptionMapper.php
index 317f7335..d1badaa3 100644
--- a/lib/Db/OptionMapper.php
+++ b/lib/Db/OptionMapper.php
@@ -34,7 +34,7 @@ use Doctrine\DBAL\Exception\TableNotFoundException;
*/
class OptionMapper extends QBMapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_options', '\OCA\Polls\Db\Option');
+ parent::__construct($db, 'polls_options', 'OCA\Polls\Db\Option');
}
/**
@@ -74,7 +74,7 @@ class OptionMapper extends QBMapper {
* @throws \OCP\AppFramework\Db\DoesNotExistException if not found
* @return Option
*/
- public function findByPollAndText($pollId, $pollOptionText): Option {
+ public function findByPollAndText(int $pollId, string $pollOptionText): Option {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
@@ -90,7 +90,7 @@ class OptionMapper extends QBMapper {
return $this->findEntity($qb);
}
- public function remove($optionId): void {
+ public function remove(int $optionId): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
@@ -101,7 +101,7 @@ class OptionMapper extends QBMapper {
$qb->execute();
}
- public function deleteByPoll($pollId): void {
+ public function deleteByPoll(int $pollId): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
diff --git a/lib/Db/Poll.php b/lib/Db/Poll.php
index 83fd8b3c..39a10ff1 100644
--- a/lib/Db/Poll.php
+++ b/lib/Db/Poll.php
@@ -156,45 +156,45 @@ class Poll extends Entity implements JsonSerializable {
protected $hideBookedUp;
public function __construct() {
- $this->addType('created', 'integer');
- $this->addType('expire', 'integer');
- $this->addType('deleted', 'integer');
- $this->addType('anonymous', 'integer');
- $this->addType('allowComment', 'integer');
- $this->addType('allowMaybe', 'integer');
- $this->addType('proposalsExpire', 'integer');
- $this->addType('voteLimit', 'integer');
- $this->addType('optionLimit', 'integer');
- $this->addType('adminAccess', 'integer');
- $this->addType('important', 'integer');
- $this->addType('hideBookedUp', 'integer');
+ $this->addType('created', 'int');
+ $this->addType('expire', 'int');
+ $this->addType('deleted', 'int');
+ $this->addType('anonymous', 'int');
+ $this->addType('allowComment', 'int');
+ $this->addType('allowMaybe', 'int');
+ $this->addType('proposalsExpire', 'int');
+ $this->addType('voteLimit', 'int');
+ $this->addType('optionLimit', 'int');
+ $this->addType('adminAccess', 'int');
+ $this->addType('important', 'int');
+ $this->addType('hideBookedUp', 'int');
}
public function jsonSerialize() {
return [
- 'id' => $this->id,
- 'type' => $this->type,
- 'title' => $this->title,
- 'description' => $this->description,
+ 'id' => $this->getId(),
+ 'type' => $this->getType(),
+ 'title' => $this->getTitle(),
+ 'description' => $this->getDescription(),
'descriptionSafe' => $this->getDescriptionSafe(),
- 'owner' => $this->owner,
- 'created' => $this->created,
- 'expire' => $this->expire,
- 'deleted' => $this->deleted,
- 'access' => $this->access,
- 'anonymous' => $this->anonymous,
- 'allowComment' => $this->allowComment,
- 'allowMaybe' => $this->allowMaybe,
- 'allowProposals' => $this->allowProposals,
- 'proposalsExpire' => $this->proposalsExpire,
- 'settings' => $this->settings,
- 'voteLimit' => $this->voteLimit,
- 'optionLimit' => $this->optionLimit,
- 'showResults' => $this->showResults === 'expired' ? Poll::SHOW_RESULTS_CLOSED : $this->showResults,
- 'adminAccess' => $this->adminAccess,
+ 'owner' => $this->getOwner(),
+ 'created' => $this->getCreated(),
+ 'expire' => $this->getExpire(),
+ 'deleted' => $this->getDeleted(),
+ 'access' => $this->getAccess(),
+ 'anonymous' => $this->getAnonymous(),
+ 'allowComment' => $this->getAllowComment(),
+ 'allowMaybe' => $this->getAllowMaybe(),
+ 'allowProposals' => $this->getAllowProposals(),
+ 'proposalsExpire' => $this->getProposalsExpire(),
+ 'settings' => $this->getSettings(),
+ 'voteLimit' => $this->getVoteLimit(),
+ 'optionLimit' => $this->getOptionLimit(),
+ 'showResults' => $this->getShowResults() === 'expired' ? Poll::SHOW_RESULTS_CLOSED : $this->getShowResults(),
+ 'adminAccess' => $this->getAdminAccess(),
'ownerDisplayName' => $this->getDisplayName(),
- 'important' => $this->important,
- 'hideBookedUp' => $this->hideBookedUp
+ 'important' => $this->getImportant(),
+ 'hideBookedUp' => $this->getHideBookedUp(),
];
}
@@ -235,7 +235,7 @@ class Poll extends Entity implements JsonSerializable {
);
}
- public function getDescriptionSafe() {
+ public function getDescriptionSafe(): string {
return htmlspecialchars($this->description);
}
diff --git a/lib/Db/PollMapper.php b/lib/Db/PollMapper.php
index 9fffdc74..4fd83d1a 100644
--- a/lib/Db/PollMapper.php
+++ b/lib/Db/PollMapper.php
@@ -33,7 +33,7 @@ use OCP\AppFramework\Db\QBMapper;
*/
class PollMapper extends QBMapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_polls', '\OCA\Polls\Db\Poll');
+ parent::__construct($db, 'polls_polls', 'OCA\Polls\Db\Poll');
}
/**
diff --git a/lib/Db/Preferences.php b/lib/Db/Preferences.php
index 4cd8d416..4f86a7a3 100644
--- a/lib/Db/Preferences.php
+++ b/lib/Db/Preferences.php
@@ -49,14 +49,14 @@ class Preferences extends Entity implements JsonSerializable {
protected $preferences;
public function __construct() {
- $this->addType('timestamp', 'integer');
+ $this->addType('timestamp', 'int');
}
public function jsonSerialize() {
return [
- 'id' => $this->id,
- 'userId' => $this->userId,
- 'timestamp' => $this->timestamp,
+ 'id' => $this->getId(),
+ 'userId' => $this->getUserId(),
+ 'timestamp' => $this->getTimestamp(),
'preferences' => json_decode($this->preferences),
];
}
diff --git a/lib/Db/PreferencesMapper.php b/lib/Db/PreferencesMapper.php
index 42bb1479..4d9554e5 100644
--- a/lib/Db/PreferencesMapper.php
+++ b/lib/Db/PreferencesMapper.php
@@ -33,7 +33,7 @@ use Doctrine\DBAL\Exception\TableNotFoundException;
*/
class PreferencesMapper extends QBMapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_preferences', '\OCA\Polls\Db\Preferences');
+ parent::__construct($db, 'polls_preferences', 'OCA\Polls\Db\Preferences');
}
/**
@@ -41,8 +41,7 @@ class PreferencesMapper extends QBMapper {
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
* @return Preferences
*/
-
- public function find($userId): Preferences {
+ public function find(string $userId): Preferences {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
diff --git a/lib/Db/Share.php b/lib/Db/Share.php
index 7be6b0fc..c7f5b37b 100644
--- a/lib/Db/Share.php
+++ b/lib/Db/Share.php
@@ -86,26 +86,26 @@ class Share extends Entity implements JsonSerializable {
protected $displayName;
public function __construct() {
- $this->addType('pollId', 'integer');
- $this->addType('invitationSent', 'integer');
+ $this->addType('pollId', 'int');
+ $this->addType('invitationSent', 'int');
}
public function jsonSerialize() {
return [
- 'id' => $this->id,
- 'token' => $this->token,
- 'type' => $this->type,
- 'pollId' => $this->pollId,
+ 'id' => $this->getId(),
+ 'token' => $this->getToken(),
+ 'type' => $this->getType(),
+ 'pollId' => $this->getPollId(),
'userId' => $this->getUserId(),
- 'emailAddress' => $this->emailAddress,
- 'invitationSent' => $this->invitationSent,
- 'displayName' => $this->displayName,
- 'isNoUser' => !($this->type === self::TYPE_USER),
- 'URL' => $this->getURL()
+ 'emailAddress' => $this->getEmailAddress(),
+ 'invitationSent' => $this->getInvitationSent(),
+ 'displayName' => $this->getDisplayName(),
+ 'isNoUser' => !($this->getType() === self::TYPE_USER),
+ 'URL' => $this->getURL(),
];
}
- public function getURL() {
+ public function getURL(): string {
if ($this->type === self::TYPE_USER || $this->type === self::TYPE_GROUP) {
return \OC::$server->getUrlGenerator()->linkToRouteAbsolute(
'polls.page.vote',
diff --git a/lib/Db/ShareMapper.php b/lib/Db/ShareMapper.php
index eb498793..0997e9c0 100644
--- a/lib/Db/ShareMapper.php
+++ b/lib/Db/ShareMapper.php
@@ -34,7 +34,7 @@ use Doctrine\DBAL\Exception\TableNotFoundException;
*/
class ShareMapper extends QBMapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_share', '\OCA\Polls\Db\Share');
+ parent::__construct($db, 'polls_share', 'OCA\Polls\Db\Share');
}
/**
@@ -105,7 +105,7 @@ class ShareMapper extends QBMapper {
/**
* @return void
*/
- public function deleteByPoll($pollId): void {
+ public function deleteByPoll(int $pollId): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
@@ -130,7 +130,7 @@ class ShareMapper extends QBMapper {
/**
* @return void
*/
- public function remove($shareId): void {
+ public function remove(int $shareId): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
diff --git a/lib/Db/Subscription.php b/lib/Db/Subscription.php
index c7cf4a2e..a2124eb6 100644
--- a/lib/Db/Subscription.php
+++ b/lib/Db/Subscription.php
@@ -45,14 +45,14 @@ class Subscription extends Entity implements JsonSerializable {
protected $userId;
public function __construct() {
- $this->addType('pollId', 'integer');
+ $this->addType('pollId', 'int');
}
public function jsonSerialize() {
return [
- 'id' => $this->id,
- 'pollId' => $this->pollId,
- 'userId' => $this->userId
+ 'id' => $this->getId(),
+ 'pollId' => $this->getPollId(),
+ 'userId' => $this->getUserId(),
];
}
}
diff --git a/lib/Db/SubscriptionMapper.php b/lib/Db/SubscriptionMapper.php
index 59275451..aead17cb 100644
--- a/lib/Db/SubscriptionMapper.php
+++ b/lib/Db/SubscriptionMapper.php
@@ -34,7 +34,7 @@ use Doctrine\DBAL\Exception\TableNotFoundException;
*/
class SubscriptionMapper extends QBMapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_notif', '\OCA\Polls\Db\Subscription');
+ parent::__construct($db, 'polls_notif', 'OCA\Polls\Db\Subscription');
}
/**
@@ -73,7 +73,7 @@ class SubscriptionMapper extends QBMapper {
* @throws \OCP\AppFramework\Db\MultipleObjectsReturnedException if more than one result
* @return Subscription
*/
- public function findByPollAndUser(int $pollId, $userId) {
+ public function findByPollAndUser(int $pollId, string $userId) {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
@@ -88,7 +88,7 @@ class SubscriptionMapper extends QBMapper {
return $this->findEntity($qb);
}
- public function unsubscribe($pollId, $userId): void {
+ public function unsubscribe(int $pollId, string $userId): void {
$qb = $this->db->getQueryBuilder();
$qb->delete($this->getTableName())
diff --git a/lib/Db/Vote.php b/lib/Db/Vote.php
index e297e66a..d46049bc 100644
--- a/lib/Db/Vote.php
+++ b/lib/Db/Vote.php
@@ -59,21 +59,21 @@ class Vote extends Entity implements JsonSerializable {
protected $voteAnswer;
public function __construct() {
- $this->addType('id', 'integer');
- $this->addType('pollId', 'integer');
- $this->addType('voteOptionId', 'integer');
+ $this->addType('id', 'int');
+ $this->addType('pollId', 'int');
+ $this->addType('voteOptionId', 'int');
}
public function jsonSerialize() {
return [
- 'id' => $this->id,
- 'pollId' => $this->pollId,
- 'userId' => $this->userId,
- 'voteOptionId' => $this->voteOptionId,
- 'voteOptionText' => $this->voteOptionText,
- 'voteAnswer' => $this->voteAnswer,
+ 'id' => $this->getId(),
+ 'pollId' => $this->getPollId(),
+ 'userId' => $this->getUserId(),
+ 'voteOptionId' => $this->getVoteOptionId(),
+ 'voteOptionText' => $this->getVoteOptionText(),
+ 'voteAnswer' => $this->getVoteAnswer(),
'isNoUser' => $this->getIsNoUser(),
- 'displayName' => $this->getDisplayName()
+ 'displayName' => $this->getDisplayName(),
];
}
diff --git a/lib/Db/VoteMapper.php b/lib/Db/VoteMapper.php
index 6be257b1..78419ae0 100644
--- a/lib/Db/VoteMapper.php
+++ b/lib/Db/VoteMapper.php
@@ -34,7 +34,7 @@ use Doctrine\DBAL\Exception\TableNotFoundException;
*/
class VoteMapper extends QBMapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_votes', '\OCA\Polls\Db\Vote');
+ parent::__construct($db, 'polls_votes', 'OCA\Polls\Db\Vote');
}
/**
@@ -102,7 +102,7 @@ class VoteMapper extends QBMapper {
*
* @psalm-return array<array-key, Vote>
*/
- public function findParticipantsVotes(int $pollId, $userId): array {
+ public function findParticipantsVotes(int $pollId, string $userId): array {
$qb = $this->db->getQueryBuilder();
$qb->select('*')
->from($this->getTableName())
@@ -119,7 +119,7 @@ class VoteMapper extends QBMapper {
->execute();
}
- public function deleteByPoll($pollId): void {
+ 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)))
diff --git a/lib/Db/Watch.php b/lib/Db/Watch.php
index c48809c5..c262e35d 100644
--- a/lib/Db/Watch.php
+++ b/lib/Db/Watch.php
@@ -34,8 +34,8 @@ use OCP\AppFramework\Db\Entity;
* @method void setPollId(integer $value)
* @method string getTable()
* @method void setTable(string $value)
- * @method string getUpdated()
- * @method void setUpdated(string $value)
+ * @method int getUpdated()
+ * @method void setUpdated(integer $value)
*/
class Watch extends Entity implements JsonSerializable {
public const OBJECT_POLLS = "polls";
@@ -49,19 +49,20 @@ class Watch extends Entity implements JsonSerializable {
/** @var string $tableId */
protected $table;
- /** @var string $updated */
+ /** @var integer $updated */
protected $updated;
public function __construct() {
- $this->addType('pollId', 'integer');
+ $this->addType('pollId', 'int');
+ $this->addType('updated', 'int');
}
public function jsonSerialize() {
return [
- 'id' => $this->id,
- 'pollId' => $this->pollId,
- 'table' => $this->table,
- 'updated' => $this->updated,
+ 'id' => $this->getId(),
+ 'pollId' => $this->getPollId(),
+ 'table' => $this->getTable(),
+ 'updated' => $this->getUpdated(),
];
}
}
diff --git a/lib/Db/WatchMapper.php b/lib/Db/WatchMapper.php
index 37e2b639..e250ff0e 100644
--- a/lib/Db/WatchMapper.php
+++ b/lib/Db/WatchMapper.php
@@ -31,7 +31,7 @@ use OCP\AppFramework\Db\QBMapper;
*/
class WatchMapper extends QBMapper {
public function __construct(IDBConnection $db) {
- parent::__construct($db, 'polls_watch', '\OCA\Polls\Db\Watch');
+ parent::__construct($db, 'polls_watch', 'OCA\Polls\Db\Watch');
}
/**
diff --git a/lib/Exceptions/BadRequestException.php b/lib/Exceptions/BadRequestException.php
index 98fef4d7..991b8512 100644
--- a/lib/Exceptions/BadRequestException.php
+++ b/lib/Exceptions/BadRequestException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class BadRequestException extends Exception {
- public function __construct($e = 'Not allowed') {
+ public function __construct(string $e = 'Not allowed') {
parent::__construct($e, Http::STATUS_BAD_REQUEST);
}
}
diff --git a/lib/Exceptions/CirclesNotEnabledException.php b/lib/Exceptions/CirclesNotEnabledException.php
index f4c76ff6..f2d99551 100644
--- a/lib/Exceptions/CirclesNotEnabledException.php
+++ b/lib/Exceptions/CirclesNotEnabledException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class CirclesNotEnabledException extends Exception {
- public function __construct($e = 'Circles is not enabled for this user') {
+ public function __construct(string $e = 'Circles is not enabled for this user') {
parent::__construct($e, Http::STATUS_NOT_FOUND);
}
}
diff --git a/lib/Exceptions/ContactGroupNotFound.php b/lib/Exceptions/ContactGroupNotFound.php
index 619c3061..4c91cdfb 100644
--- a/lib/Exceptions/ContactGroupNotFound.php
+++ b/lib/Exceptions/ContactGroupNotFound.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class ContactGroupNotFound extends Exception {
- public function __construct($e = 'Contact Group not found') {
+ public function __construct(string $e = 'Contact Group not found') {
parent::__construct($e, Http::STATUS_NOT_FOUND);
}
}
diff --git a/lib/Exceptions/ContactsNotEnabledExceptions.php b/lib/Exceptions/ContactsNotEnabledExceptions.php
index ef44d9df..7eb16ed2 100644
--- a/lib/Exceptions/ContactsNotEnabledExceptions.php
+++ b/lib/Exceptions/ContactsNotEnabledExceptions.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class ContactsNotEnabledExceptions extends Exception {
- public function __construct($e = 'Contacts is not enabled') {
+ public function __construct(string $e = 'Contacts is not enabled') {
parent::__construct($e, Http::STATUS_NOT_FOUND);
}
}
diff --git a/lib/Exceptions/DuplicateEntryException.php b/lib/Exceptions/DuplicateEntryException.php
index a96a39ec..1d2e51c9 100644
--- a/lib/Exceptions/DuplicateEntryException.php
+++ b/lib/Exceptions/DuplicateEntryException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class DuplicateEntryException extends Exception {
- public function __construct($e = 'Duplicate Entry') {
+ public function __construct(string $e = 'Duplicate Entry') {
parent::__construct($e, Http::STATUS_CONFLICT);
}
}
diff --git a/lib/Exceptions/EmptyTitleException.php b/lib/Exceptions/EmptyTitleException.php
index bc7553a2..c19f0505 100644
--- a/lib/Exceptions/EmptyTitleException.php
+++ b/lib/Exceptions/EmptyTitleException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class EmptyTitleException extends Exception {
- public function __construct($e = 'Poll title must not be empty') {
+ public function __construct(string $e = 'Poll title must not be empty') {
parent::__construct($e, Http::STATUS_CONFLICT);
}
}
diff --git a/lib/Exceptions/Exception.php b/lib/Exceptions/Exception.php
index e5ea0a2a..de338e78 100644
--- a/lib/Exceptions/Exception.php
+++ b/lib/Exceptions/Exception.php
@@ -31,8 +31,8 @@ class Exception extends \Exception {
protected $status;
public function __construct(
- $e = 'Unexpected error',
- $status = Http::STATUS_INTERNAL_SERVER_ERROR
+ string $e = 'Unexpected error',
+ int $status = Http::STATUS_INTERNAL_SERVER_ERROR
) {
parent::__construct($e);
$this->status = $status;
diff --git a/lib/Exceptions/InvalidAccessException.php b/lib/Exceptions/InvalidAccessException.php
index 16fffb0f..1b3ca32c 100644
--- a/lib/Exceptions/InvalidAccessException.php
+++ b/lib/Exceptions/InvalidAccessException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class InvalidAccessException extends Exception {
- public function __construct($e = 'Invalid access value') {
+ public function __construct(string $e = 'Invalid access value') {
parent::__construct($e, Http::STATUS_CONFLICT);
}
}
diff --git a/lib/Exceptions/InvalidEmailAddress.php b/lib/Exceptions/InvalidEmailAddress.php
index c11557d5..76bbb66e 100644
--- a/lib/Exceptions/InvalidEmailAddress.php
+++ b/lib/Exceptions/InvalidEmailAddress.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class InvalidEmailAddress extends Exception {
- public function __construct($e = 'Invalid email address') {
+ public function __construct(string $e = 'Invalid email address') {
parent::__construct($e, Http::STATUS_FORBIDDEN);
}
}
diff --git a/lib/Exceptions/InvalidOptionPropertyException.php b/lib/Exceptions/InvalidOptionPropertyException.php
new file mode 100644
index 00000000..7d7773b2
--- /dev/null
+++ b/lib/Exceptions/InvalidOptionPropertyException.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * @copyright Copyright (c) 2020 René Gieling <github@dartcafe.de>
+ *
+ * @author René Gieling <github@dartcafe.de>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Polls\Exceptions;
+
+use OCP\AppFramework\Http;
+
+class InvalidOptionPropertyException extends Exception {
+ public function __construct(string $e = 'Invalid option attributes') {
+ parent::__construct($e, Http::STATUS_CONFLICT);
+ }
+}
diff --git a/lib/Exceptions/InvalidPollTypeException.php b/lib/Exceptions/InvalidPollTypeException.php
index fe47bed0..80892fdb 100644
--- a/lib/Exceptions/InvalidPollTypeException.php
+++ b/lib/Exceptions/InvalidPollTypeException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class InvalidPollTypeException extends Exception {
- public function __construct($e = 'Invalid pollType value') {
+ public function __construct(string $e = 'Invalid pollType value') {
parent::__construct($e, Http::STATUS_CONFLICT);
}
}
diff --git a/lib/Exceptions/InvalidShareTypeException.php b/lib/Exceptions/InvalidShareTypeException.php
index 17888161..8cac5b19 100644
--- a/lib/Exceptions/InvalidShareTypeException.php
+++ b/lib/Exceptions/InvalidShareTypeException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class InvalidShareTypeException extends Exception {
- public function __construct($e = 'Invalid share type') {
+ public function __construct(string $e = 'Invalid share type') {
parent::__construct($e, Http::STATUS_CONFLICT);
}
}
diff --git a/lib/Exceptions/InvalidShowResultsException.php b/lib/Exceptions/InvalidShowResultsException.php
index 4474abf7..3bdcc37b 100644
--- a/lib/Exceptions/InvalidShowResultsException.php
+++ b/lib/Exceptions/InvalidShowResultsException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class InvalidShowResultsException extends Exception {
- public function __construct($e = 'Invalid showResults value') {
+ public function __construct(string $e = 'Invalid showResults value') {
parent::__construct($e, Http::STATUS_CONFLICT);
}
}
diff --git a/lib/Exceptions/InvalidUsernameException.php b/lib/Exceptions/InvalidUsernameException.php
index e1317f6c..9fd0f584 100644
--- a/lib/Exceptions/InvalidUsernameException.php
+++ b/lib/Exceptions/InvalidUsernameException.php
@@ -30,7 +30,7 @@ class InvalidUsernameException extends Exception {
* InvalidUsernameException Constructor
* @param string $e exception message
*/
- public function __construct($e = 'Username not allowed') {
+ public function __construct(string $e = 'Username not allowed') {
parent::__construct($e, Http::STATUS_FORBIDDEN);
}
}
diff --git a/lib/Exceptions/MultipleContactsFound.php b/lib/Exceptions/MultipleContactsFound.php
index b9b81225..59ed77f1 100644
--- a/lib/Exceptions/MultipleContactsFound.php
+++ b/lib/Exceptions/MultipleContactsFound.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class MultipleContactsFound extends Exception {
- public function __construct($e = 'Multiple Contacts found') {
+ public function __construct(string $e = 'Multiple Contacts found') {
parent::__construct($e, Http::STATUS_CONFLICT);
}
}
diff --git a/lib/Exceptions/NoUpdatesException.php b/lib/Exceptions/NoUpdatesException.php
index a0f836c6..cb2e6e14 100644
--- a/lib/Exceptions/NoUpdatesException.php
+++ b/lib/Exceptions/NoUpdatesException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class NoUpdatesException extends Exception {
- public function __construct($e = 'No updates') {
+ public function __construct(string $e = 'No updates') {
parent::__construct($e, Http::STATUS_NOT_MODIFIED);
}
}
diff --git a/lib/Exceptions/NotAuthorizedException.php b/lib/Exceptions/NotAuthorizedException.php
index 40e18410..71e9eace 100644
--- a/lib/Exceptions/NotAuthorizedException.php
+++ b/lib/Exceptions/NotAuthorizedException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class NotAuthorizedException extends Exception {
- public function __construct($e = 'Unauthorized or not found') {
+ public function __construct(string $e = 'Unauthorized or not found') {
parent::__construct($e, Http::STATUS_UNAUTHORIZED);
}
}
diff --git a/lib/Exceptions/NotFoundException.php b/lib/Exceptions/NotFoundException.php
index 9fe69465..736516a6 100644
--- a/lib/Exceptions/NotFoundException.php
+++ b/lib/Exceptions/NotFoundException.php
@@ -27,8 +27,8 @@ use OCP\AppFramework\Http;
class NotFoundException extends Exception {
public function __construct(
- $e = 'Not found',
- $status = Http::STATUS_NOT_FOUND) {
+ string $e = 'Not found',
+ int $status = Http::STATUS_NOT_FOUND) {
parent::__construct($e, $status);
}
}
diff --git a/lib/Exceptions/ShareAlreadyExistsException.php b/lib/Exceptions/ShareAlreadyExistsException.php
index bf08d58a..05cad831 100644
--- a/lib/Exceptions/ShareAlreadyExistsException.php
+++ b/lib/Exceptions/ShareAlreadyExistsException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class ShareAlreadyExistsException extends Exception {
- public function __construct($e = 'Share already exists') {
+ public function __construct(string $e = 'Share already exists') {
parent::__construct($e, Http::STATUS_OK);
}
}
diff --git a/lib/Exceptions/TooShortException.php b/lib/Exceptions/TooShortException.php
index 85d9c868..393c2678 100644
--- a/lib/Exceptions/TooShortException.php
+++ b/lib/Exceptions/TooShortException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class TooShortException extends Exception {
- public function __construct($e = 'String too short') {
+ public function __construct(string $e = 'String too short') {
parent::__construct($e, Http::STATUS_FORBIDDEN);
}
}
diff --git a/lib/Exceptions/VoteLimitExceededException.php b/lib/Exceptions/VoteLimitExceededException.php
index e07418f3..a5632c46 100644
--- a/lib/Exceptions/VoteLimitExceededException.php
+++ b/lib/Exceptions/VoteLimitExceededException.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Exceptions;
use OCP\AppFramework\Http;
class VoteLimitExceededException extends Exception {
- public function __construct($e = 'Vote limit exceeded') {
+ public function __construct(string $e = 'Vote limit exceeded') {
parent::__construct($e, Http::STATUS_CONFLICT);
}
}
diff --git a/lib/Helper/Trace.php b/lib/Helper/Trace.php
index c8cfbea0..e6047e72 100644
--- a/lib/Helper/Trace.php
+++ b/lib/Helper/Trace.php
@@ -39,7 +39,7 @@ class Trace implements \JsonSerializable {
$this->log('Initialization', $payload);
}
- public function log($operation, $payload = '') {
+ public function log(string $operation, string $payload = ''): void {
$this->result[] = [
'method' => $this->method,
'time' => time(),
diff --git a/lib/Listener/UserDeletedListener.php b/lib/Listener/UserDeletedListener.php
index 4f935a30..29f38e20 100644
--- a/lib/Listener/UserDeletedListener.php
+++ b/lib/Listener/UserDeletedListener.php
@@ -27,7 +27,6 @@ use OCA\Polls\Cron\UserDeletedJob;
use OCP\BackgroundJob\IJobList;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
-use OCP\ILogger;
use OCP\User\Events\UserDeletedEvent;
class UserDeletedListener implements IEventListener {
@@ -35,13 +34,8 @@ class UserDeletedListener implements IEventListener {
/** @var IJobList */
private $jobList;
- /** @var ILogger */
- private $logger;
-
- public function __construct(IJobList $jobList,
- ILogger $logger) {
+ public function __construct(IJobList $jobList) {
$this->jobList = $jobList;
- $this->logger = $logger;
}
public function handle(Event $event): void {
diff --git a/lib/Migration/CreateIndices.php b/lib/Migration/CreateIndices.php
index 85628962..d48013a9 100644
--- a/lib/Migration/CreateIndices.php
+++ b/lib/Migration/CreateIndices.php
@@ -42,6 +42,9 @@ class CreateIndices implements IRepairStep {
return 'Create polls table indices';
}
+ /**
+ * @return void
+ */
public function run(IOutput $output) {
$this->createIndex('polls_options', 'UNIQ_options', ['poll_id', 'poll_option_text', 'timestamp'], true);
$this->createIndex('polls_log', 'UNIQ_unprocessed', ['processed', 'poll_id', 'user_id', 'message_id'], true);
@@ -54,8 +57,10 @@ class CreateIndices implements IRepairStep {
/**
* Create index for $table
+ *
+ * @return void
*/
- private function createIndex(string $tableName, string $indexName, array $columns, bool $unique = false) {
+ private function createIndex(string $tableName, string $indexName, array $columns, bool $unique = false): void {
$schema = new SchemaWrapper($this->connection);
if ($schema->hasTable($tableName)) {
$table = $schema->getTable($tableName);
diff --git a/lib/Migration/DeleteDuplicates.php b/lib/Migration/DeleteDuplicates.php
index b765ea53..af181b86 100644
--- a/lib/Migration/DeleteDuplicates.php
+++ b/lib/Migration/DeleteDuplicates.php
@@ -78,6 +78,8 @@ class DeleteDuplicates implements IRepairStep {
/**
* @inheritdoc
+ *
+ * @return void
*/
public function run(IOutput $output) {
$this->logMapper->removeDuplicates();
diff --git a/lib/Migration/RemoveIndices.php b/lib/Migration/RemoveIndices.php
index 42a39964..7a2b549e 100644
--- a/lib/Migration/RemoveIndices.php
+++ b/lib/Migration/RemoveIndices.php
@@ -40,6 +40,9 @@ class RemoveIndices implements IRepairStep {
return 'Remove polls table indices';
}
+ /**
+ * @return void
+ */
public function run(IOutput $output) {
$this->removeUniqueIndices('polls_options');
$this->removeUniqueIndices('polls_log');
@@ -52,9 +55,11 @@ class RemoveIndices implements IRepairStep {
}
/**
- * remove an index with $indexName from $table
+ * * remove an index with $indexName from $table
+ *
+ * @return void
*/
- private function removeIndex(string $tableName, string $indexName) {
+ private function removeIndex(string $tableName, string $indexName): void {
$schema = new SchemaWrapper($this->connection);
if ($schema->hasTable($tableName)) {
$table = $schema->getTable($tableName);
@@ -66,9 +71,11 @@ class RemoveIndices implements IRepairStep {
}
/**
- * remove all UNIQUE indices from $table
+ * * remove all UNIQUE indices from $table
+ *
+ * @return void
*/
- private function removeUniqueIndices(string $tableName) {
+ private function removeUniqueIndices(string $tableName): void {
$schema = new SchemaWrapper($this->connection);
if ($schema->hasTable($tableName)) {
$table = $schema->getTable($tableName);
diff --git a/lib/Migration/Version0009Date20181125061900.php b/lib/Migration/Version0009Date20181125061900.php
index ef46923a..36b4181c 100644
--- a/lib/Migration/Version0009Date20181125061900.php
+++ b/lib/Migration/Version0009Date20181125061900.php
@@ -327,7 +327,7 @@ class Version0009Date20181125061900 extends SimpleMigrationStep {
$result->closeCursor();
}
- protected function findOptionId($pollId, ?string $text) {
+ protected function findOptionId(int $pollId, ?string $text): int {
$queryFind = $this->connection->getQueryBuilder();
$queryFind->select(['id'])
->from('polls_options')
@@ -347,7 +347,7 @@ class Version0009Date20181125061900 extends SimpleMigrationStep {
}
}
- protected function translateVoteTypeToAnswer($voteType): string {
+ protected function translateVoteTypeToAnswer(string $voteType): string {
switch ($voteType) {
case 0:
$answer = "no";
diff --git a/lib/Migration/Version0010Date20191227063812.php b/lib/Migration/Version0010Date20191227063812.php
index 7482286c..7112770b 100644
--- a/lib/Migration/Version0010Date20191227063812.php
+++ b/lib/Migration/Version0010Date20191227063812.php
@@ -237,7 +237,7 @@ class Version0010Date20191227063812 extends SimpleMigrationStep {
}
- private function resolveAccess($access): string {
+ private function resolveAccess(string $access): string {
if ($access === 'public') {
return 'public';
}
@@ -245,9 +245,9 @@ class Version0010Date20191227063812 extends SimpleMigrationStep {
}
/**
- * @return false|string
+ * @return string
*/
- private function resolveOptions($maybe) {
+ private function resolveOptions(bool $maybe) {
if ($maybe) {
return json_encode(['yes', 'no', 'maybe']);
}
diff --git a/lib/Model/Acl.php b/lib/Model/Acl.php
index fba39bae..eff2ba89 100644
--- a/lib/Model/Acl.php
+++ b/lib/Model/Acl.php
@@ -135,7 +135,7 @@ class Acl implements JsonSerializable {
return $this->poll->getId();
}
- public function getUserId() {
+ public function getUserId(): string {
return $this->getLoggedIn() ? \OC::$server->getUserSession()->getUser()->getUID() : $this->share->getUserId();
}
diff --git a/lib/Model/CalendarEvent.php b/lib/Model/CalendarEvent.php
index 70fe8fb9..8cded2e6 100644
--- a/lib/Model/CalendarEvent.php
+++ b/lib/Model/CalendarEvent.php
@@ -45,7 +45,7 @@ class CalendarEvent implements \JsonSerializable {
$this->event = $this->calDav['objects'][0];
}
- public function getAllDay() {
+ public function getAllDay(): string {
return ($this->getEnd() - $this->getStart() === 86400) ? $this->event['DTSTART'][0]->format('Y-m-d') : '';
}
@@ -61,42 +61,47 @@ class CalendarEvent implements \JsonSerializable {
return $this->calendar->getDisplayColor();
}
- public function getId() {
+ public function getId(): string {
return $this->calDav['id'];
}
- public function getUID() {
+ public function getUID(): string {
return $this->event['UID'][0];
}
- public function getSummary() {
+ public function getSummary(): string {
return $this->event['SUMMARY'][0];
}
- public function getDescription() {
+ public function getDescription(): string {
return $this->event['DESCRIPTION'][0] ?? '';
}
- public function getLocation() {
+ public function getLocation(): string {
return $this->event['LOCATION'][0] ?? '';
}
- public function getStart() {
+ public function getStart(): int {
return isset($this->event['DTSTART'][0]) ? $this->event['DTSTART'][0]->getTimestamp() : 0;
}
- public function getEnd() {
+ public function getEnd(): int {
return isset($this->event['DTEND'][0])? $this->event['DTEND'][0]->getTimestamp() : 0;
}
- public function getHasRRule() {
+ public function getHasRRule(): bool {
return isset($this->event['RRULE']);
}
- public function getRecurrencies() {
+ public function getRecurrencies(): string {
return 'not implementend yet';
}
+ /**
+ * @return false|string[]
+ *
+ * @psalm-return array<string, string>|false
+ */
public function getRRule() {
$rRule = [];
if ($this->getHasRRule()) {
@@ -106,7 +111,7 @@ class CalendarEvent implements \JsonSerializable {
return $rRule;
}
- public function getStatus() {
+ public function getStatus(): string {
return $this->event['STATUS'][0] ?? '';
}
diff --git a/lib/Model/Circle.php b/lib/Model/Circle.php
index e5b082f6..cfe3464c 100644
--- a/lib/Model/Circle.php
+++ b/lib/Model/Circle.php
@@ -26,7 +26,7 @@ namespace OCA\Polls\Model;
use OCP\App\IAppManager;
use OCA\Circles\Api\v1\Circles;
-use \OCA\Circles\Model\Circle as CirclesCircle;
+use OCA\Circles\Model\Circle as CirclesCircle;
use OCA\Polls\Exceptions\CirclesNotEnabledException;
class Circle extends UserGroupClass {
@@ -37,7 +37,7 @@ class Circle extends UserGroupClass {
private $circle;
public function __construct(
- $id
+ string $id
) {
parent::__construct($id, self::TYPE);
if (self::isEnabled()) {
@@ -57,7 +57,7 @@ class Circle extends UserGroupClass {
/**
* @return Circle[]
*/
- public static function search(string $query = '', $skip = []): array {
+ public static function search(string $query = '', array $skip = []): array {
$circles = [];
if (self::isEnabled()) {
foreach (Circles::listCircles(CirclesCircle::CIRCLES_ALL, $query) as $circle) {
@@ -73,7 +73,7 @@ class Circle extends UserGroupClass {
/**
* @return User[]|Email[]|Contact[]
*/
- public function getMembers() {
+ public function getMembers(): array {
$members = [];
if (self::isEnabled()) {
foreach (Circles::detailsCircle($this->id)->getMembers() as $circleMember) {
diff --git a/lib/Model/Contact.php b/lib/Model/Contact.php
index d60742fd..31bf2f5a 100644
--- a/lib/Model/Contact.php
+++ b/lib/Model/Contact.php
@@ -36,7 +36,7 @@ class Contact extends UserGroupClass {
private $contact = [];
public function __construct(
- $id
+ string $id
) {
parent::__construct($id, self::TYPE);
if (self::isEnabled()) {
@@ -129,7 +129,7 @@ class Contact extends UserGroupClass {
/**
* @return Contact[]
*/
- public static function search(string $query = '', $queryRange = ['FN', 'EMAIL', 'ORG', 'CATEGORIES']): array {
+ public static function search(string $query = '', array $queryRange = ['FN', 'EMAIL', 'ORG', 'CATEGORIES']): array {
$contacts = [];
foreach (self::listRaw($query, $queryRange) as $contact) {
$contacts[] = new self($contact['UID']);
diff --git a/lib/Model/ContactGroup.php b/lib/Model/ContactGroup.php
index 64681b65..c89d671b 100644
--- a/lib/Model/ContactGroup.php
+++ b/lib/Model/ContactGroup.php
@@ -33,7 +33,7 @@ class ContactGroup extends UserGroupClass {
public const ICON = 'icon-group';
public function __construct(
- $id
+ string $id
) {
parent::__construct($id, self::TYPE);
if (self::isEnabled()) {
@@ -58,7 +58,7 @@ class ContactGroup extends UserGroupClass {
* Get a list of contacts group members
* @return Contact[]
*/
- public function getMembers() {
+ public function getMembers(): array {
$contacts = [];
foreach (self::getContainer()->query(IContactsManager::class)->search($this->id, ['CATEGORIES']) as $contact) {
diff --git a/lib/Model/Email.php b/lib/Model/Email.php
index 3bf161b4..674d7821 100644
--- a/lib/Model/Email.php
+++ b/lib/Model/Email.php
@@ -29,8 +29,8 @@ class Email extends UserGroupClass {
public const ICON = 'icon-mail';
public function __construct(
- $id,
- $displayName = ''
+ string $id,
+ string $displayName = ''
) {
parent::__construct($id, self::TYPE);
$this->description = \OC::$server->getL10N('polls')->t('External Email');
diff --git a/lib/Model/GenericUser.php b/lib/Model/GenericUser.php
index 81514976..de89c6f1 100644
--- a/lib/Model/GenericUser.php
+++ b/lib/Model/GenericUser.php
@@ -30,10 +30,10 @@ class GenericUser extends UserGroupClass {
public const ICON_PUBLIC = 'icon-public';
public function __construct(
- $id,
- $type = self::TYPE,
- $displayName = '',
- $emailAddress = ''
+ string $id,
+ string $type = self::TYPE,
+ string $displayName = '',
+ string $emailAddress = ''
) {
parent::__construct($id, $type);
$this->displayName = $displayName;
diff --git a/lib/Model/Group.php b/lib/Model/Group.php
index 7a48aa0b..129f9a7b 100644
--- a/lib/Model/Group.php
+++ b/lib/Model/Group.php
@@ -35,7 +35,7 @@ class Group extends UserGroupClass {
private $group;
public function __construct(
- $id
+ string $id
) {
parent::__construct($id, self::TYPE);
$this->icon = self::ICON;
diff --git a/lib/Model/User.php b/lib/Model/User.php
index 9c3ed08d..0f01420d 100644
--- a/lib/Model/User.php
+++ b/lib/Model/User.php
@@ -35,7 +35,7 @@ class User extends UserGroupClass {
private $user;
public function __construct(
- $id
+ string $id
) {
parent::__construct($id, self::TYPE);
$this->icon = self::ICON;
diff --git a/lib/Model/UserGroupClass.php b/lib/Model/UserGroupClass.php
index 3b321c49..81ddd6b8 100644
--- a/lib/Model/UserGroupClass.php
+++ b/lib/Model/UserGroupClass.php
@@ -25,6 +25,7 @@ namespace OCA\Polls\Model;
use OCA\Polls\Exceptions\InvalidShareTypeException;
+use OCP\IL10N;
use OCP\Collaboration\Collaborators\ISearch;
use OCP\Share\IShare;
use OCA\Polls\AppInfo\Application;
@@ -40,6 +41,7 @@ class UserGroupClass implements \JsonSerializable {
public const TYPE_GROUP = Group::TYPE;
public const TYPE_USER = User::TYPE;
+ /** @var IL10N */
private $l10n;
/** @var string */
@@ -73,11 +75,11 @@ class UserGroupClass implements \JsonSerializable {
protected $categories = [];
public function __construct(
- $id,
- $type,
- $displayName = '',
- $emailAddress = '',
- $language = ''
+ string $id,
+ string $type,
+ string $displayName = '',
+ string $emailAddress = '',
+ string $language = ''
) {
$this->id = $id;
$this->type = $type;
@@ -124,7 +126,7 @@ class UserGroupClass implements \JsonSerializable {
}
public function getEmailAddress(): string {
- return $this->emailAddress ?? '';
+ return $this->emailAddress;
}
public function getOrganisation(): string {
@@ -169,7 +171,7 @@ class UserGroupClass implements \JsonSerializable {
return $this->language;
}
- public function setOrganisation($organisation): string {
+ public function setOrganisation(string $organisation): string {
$this->organisation = $organisation;
return $this->organisation;
}
@@ -224,7 +226,7 @@ class UserGroupClass implements \JsonSerializable {
/**
* @return array
*/
- public function getMembers() {
+ public function getMembers(): array {
return [];
}
diff --git a/lib/Service/CalendarService.php b/lib/Service/CalendarService.php
index 6969f32c..99997a0a 100644
--- a/lib/Service/CalendarService.php
+++ b/lib/Service/CalendarService.php
@@ -25,13 +25,23 @@
namespace OCA\Polls\Service;
use DateTime;
+use OCP\Calendar\ICalendar;
use OCP\Calendar\IManager as CalendarManager;
use OCA\Polls\Model\CalendarEvent;
+use OCA\Polls\Db\Preferences;
class CalendarService {
+
+ /** @var CalendarManager */
private $calendarManager;
+
+ /** @var ICalendar[] */
private $calendars;
+
+ /** @var PreferencesService */
private $preferencesService;
+
+ /** @var Preferences */
private $preferences;
public function __construct(
diff --git a/lib/Service/MailService.php b/lib/Service/MailService.php
index cc4465d4..1435da64 100644
--- a/lib/Service/MailService.php
+++ b/lib/Service/MailService.php
@@ -299,11 +299,7 @@ class MailService {
$this->logMapper->update($logItem);
}
- $emailTemplate->addBodyButton(
- htmlspecialchars($this->trans->t('Go to poll')),
- $url,
- /** @scrutinizer ignore-type */ false
- );
+ $emailTemplate->addBodyButton(htmlspecialchars($this->trans->t('Go to poll')), $url, '');
$emailTemplate->addFooter($this->trans->t('This email is sent to you, because you subscribed to notifications of this poll. To opt out, visit the poll and remove your subscription.'));
return $emailTemplate;
diff --git a/lib/Service/NotificationService.php b/lib/Service/NotificationService.php
index c41d4898..41ac0519 100644
--- a/lib/Service/NotificationService.php
+++ b/lib/Service/NotificationService.php
@@ -38,7 +38,7 @@ class NotificationService {
public function __construct(
IManager $notificationManager,
- $UserId
+ string $UserId
) {
$this->notificationManager = $notificationManager;
$this->userId = $UserId;
@@ -52,7 +52,7 @@ class NotificationService {
$this->notificationManager->markProcessed($notification);
}
- public function sendInvitation(int $pollId, $recipient): bool {
+ public function sendInvitation(int $pollId, string $recipient): bool {
$notification = $this->notificationManager->createNotification();
$notification->setApp(self::APP_ID)
->setUser($recipient)
diff --git a/lib/Service/OptionService.php b/lib/Service/OptionService.php
index e2c933ff..0fdcc27d 100644
--- a/lib/Service/OptionService.php
+++ b/lib/Service/OptionService.php
@@ -30,6 +30,7 @@ use OCA\Polls\Exceptions\NotAuthorizedException;
use OCA\Polls\Exceptions\BadRequestException;
use OCA\Polls\Exceptions\DuplicateEntryException;
use OCA\Polls\Exceptions\InvalidPollTypeException;
+use OCA\Polls\Exceptions\InvalidOptionPropertyException;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use OCA\Polls\Db\OptionMapper;
@@ -441,14 +442,16 @@ class OptionService {
if ($this->poll->getType() === Poll::TYPE_DATE) {
$this->option->setTimestamp($timestamp);
$this->option->setOrder($timestamp);
- $this->option->setDuration($duration);
+ $this->option->setDuration($duration ?? 0);
if ($duration > 0) {
$this->option->setPollOptionText(date('c', $timestamp) . ' - ' . date('c', $timestamp + $duration));
} else {
$this->option->setPollOptionText(date('c', $timestamp));
}
- } else {
+ } elseif ($pollOptionText){
$this->option->setPollOptionText($pollOptionText);
+ } else {
+ throw new InvalidOptionPropertyException('Option must have a value');
}
}
@@ -482,7 +485,7 @@ class OptionService {
private function filterBookedUp() {
$exceptVotes = $this->getUsersVotes();
$this->options = array_filter($this->options, function ($option) use ($exceptVotes) {
- return (!$option->getIsBookedUp() || in_array($option->getPollOptionText(), $exceptVotes));
+ return (!$option->isBookedUp || in_array($option->getPollOptionText(), $exceptVotes));
});
}
@@ -538,7 +541,7 @@ class OptionService {
*/
private function calculateRanks() {
// sort array by yes and maybe votes
- usort($this->options, function ($a, $b) {
+ usort($this->options, function (Option $a, Option $b):int {
$diff = $b->yes - $a->yes;
return ($diff !== 0) ? $diff : $b->maybe - $a->maybe;
});
@@ -554,7 +557,7 @@ class OptionService {
}
// restore original order
- usort($this->options, function ($a, $b) {
+ usort($this->options, function (Option $a, Option $b):int {
return $a->getOrder() - $b->getOrder();
});
}
diff --git a/lib/Service/PollService.php b/lib/Service/PollService.php
index a2f819cd..a0945f40 100644
--- a/lib/Service/PollService.php
+++ b/lib/Service/PollService.php
@@ -177,7 +177,7 @@ class PollService {
/**
* Add poll
*/
- public function add(string $type, string $title) {
+ public function add(string $type, string $title): Poll {
if (!\OC::$server->getUserSession()->isLoggedIn()) {
throw new NotAuthorizedException;
}
diff --git a/lib/Service/PreferencesService.php b/lib/Service/PreferencesService.php
index 19efb62d..bc4f4d81 100644
--- a/lib/Service/PreferencesService.php
+++ b/lib/Service/PreferencesService.php
@@ -41,7 +41,7 @@ class PreferencesService {
private $userId;
public function __construct(
- $UserId,
+ string $UserId,
PreferencesMapper $preferencesMapper
) {
$this->userId = $UserId;
@@ -73,7 +73,7 @@ class PreferencesService {
*
* @return Preferences
*/
- public function write($settings): Preferences {
+ public function write(string $settings): Preferences {
if (!$this->userId) {
throw new NotAuthorizedException;
}
diff --git a/lib/Service/ShareService.php b/lib/Service/ShareService.php
index d4068b52..242440cc 100644
--- a/lib/Service/ShareService.php
+++ b/lib/Service/ShareService.php
@@ -151,7 +151,7 @@ class ShareService {
/**
* Get share by token
*/
- public function get(string $token, bool $validate = false) {
+ public function get(string $token, bool $validate = false): Share {
try {
$this->share = $this->shareMapper->findByToken($token);
if ($validate) {
diff --git a/lib/Service/SystemService.php b/lib/Service/SystemService.php
index 41c70542..fe99f1aa 100644
--- a/lib/Service/SystemService.php
+++ b/lib/Service/SystemService.php
@@ -79,9 +79,10 @@ class SystemService {
/**
* Get a list of users
+ * @param string $query
* @param string[] $skip
*/
- public static function getSiteUsers(string $query = '', array $skip = []) {
+ public static function getSiteUsers(string $query = '', array $skip = []): array {
$users = [];
foreach (\OC::$server->getUserManager()->searchDisplayName($query) as $user) {
if (!in_array($user->getUID(), $skip) && $user->isEnabled()) {