diff --git a/lib/Activity/Provider.php b/lib/Activity/Provider.php index 2562178..4c8d431 100644 --- a/lib/Activity/Provider.php +++ b/lib/Activity/Provider.php @@ -97,7 +97,7 @@ class Provider implements IProvider { return $event; } - private function parseRoomCreated(IEvent $event) { + private function parseRoomCreated(IEvent $event): void { $params = $event->getSubjectParameters(); $event->setParsedSubject($this->l->t('You created the room %s.', [$params['name']])); @@ -105,7 +105,7 @@ class Provider implements IProvider { $this->setIcon($event, 'room-created'); } - private function parseRoomDeleted(IEvent $event) { + private function parseRoomDeleted(IEvent $event): void { $params = $event->getSubjectParameters(); if ($this->activityManager->getCurrentUserId() === $event->getAuthor()) { @@ -121,7 +121,7 @@ class Provider implements IProvider { $this->setIcon($event, 'room-deleted'); } - private function parseShareCreated(IEvent $event) { + private function parseShareCreated(IEvent $event): void { $params = $event->getSubjectParameters(); if ($this->activityManager->getCurrentUserId() === $event->getAuthor()) { @@ -138,7 +138,7 @@ class Provider implements IProvider { $this->setIcon($event, 'share-created'); } - private function parseShareDeleted(IEvent $event) { + private function parseShareDeleted(IEvent $event): void { $params = $event->getSubjectParameters(); if ($this->activityManager->getCurrentUserId() === $event->getAuthor()) { @@ -155,7 +155,7 @@ class Provider implements IProvider { $this->setIcon($event, 'share-deleted'); } - private function parseMeetingStarted(IEvent $event) { + private function parseMeetingStarted(IEvent $event): void { $params = $event->getSubjectParameters(); if ($this->activityManager->getCurrentUserId() === $event->getAuthor()) { @@ -171,7 +171,7 @@ class Provider implements IProvider { $this->setIcon($event, 'meeting-started'); } - private function parseMeetingEnded(IEvent $event) { + private function parseMeetingEnded(IEvent $event): void { $params = $event->getSubjectParameters(); $event->setParsedSubject($this->l->t('The meeting in room "%s" has ended.', [$params['name']])); @@ -179,7 +179,7 @@ class Provider implements IProvider { $this->setIcon($event, 'meeting-ended'); } - private function parseRecordingReady(IEvent $event) { + private function parseRecordingReady(IEvent $event): void { $params = $event->getSubjectParameters(); $event->setParsedSubject($this->l->t('Recording for room "%s" is ready.', [$params['name']])); @@ -187,7 +187,7 @@ class Provider implements IProvider { $this->setIcon($event, 'recording-ready'); } - private function setIcon(IEvent $event, string $baseName) { + private function setIcon(IEvent $event, string $baseName): void { if ($this->activityManager->getRequirePNG()) { $imagePath = $this->url->imagePath(Application::ID, 'actions/'.$baseName.'.png'); } else { @@ -197,7 +197,7 @@ class Provider implements IProvider { $event->setIcon($this->url->getAbsoluteURL($imagePath)); } - private function setSubjects(IEvent $event, string $subject, array $parameters) { + private function setSubjects(IEvent $event, string $subject, array $parameters): void { $placeholders = $replacements = []; foreach ($parameters as $placeholder => $parameter) { @@ -213,7 +213,12 @@ class Provider implements IProvider { ->setRichSubject($subject, $parameters); } - protected function getUser(string $uid) { + /** + * @return string[] + * + * @psalm-return array{type: string, id: string, name: string} + */ + protected function getUser(string $uid): array { $user = $this->userManager->get($uid); if ($user instanceof IUser) { @@ -231,7 +236,12 @@ class Provider implements IProvider { ]; } - protected function getGroup($uid) { + /** + * @return (mixed|string)[] + * + * @psalm-return array{type: string, id: mixed|string, name: mixed|string} + */ + protected function getGroup($uid): array { $group = $this->groupManager->get($uid); if ($group !== null) { diff --git a/lib/Activity/RoomShareListener.php b/lib/Activity/RoomShareListener.php index 4dbdff7..b4695cf 100644 --- a/lib/Activity/RoomShareListener.php +++ b/lib/Activity/RoomShareListener.php @@ -53,11 +53,14 @@ class RoomShareListener implements IEventListener { } } - private function shareWithUser(string $subject, Room $room, RoomShare $share) { + private function shareWithUser(string $subject, Room $room, RoomShare $share): void { $this->createActivityEvent($subject, $room->getUserId(), $room, $share); $this->createActivityEvent($subject, $share->getShareWith(), $room, $share); } + /** + * @return void + */ private function shareWithGroup(string $subject, Room $room, RoomShare $share) { $this->createActivityEvent($subject, $room->getUserId(), $room, $share); @@ -72,7 +75,7 @@ class RoomShareListener implements IEventListener { } } - private function createActivityEvent(string $subject, string $affectedUser, Room $room, RoomShare $roomShare) { + private function createActivityEvent(string $subject, string $affectedUser, Room $room, RoomShare $roomShare): void { $activityEvent = $this->activityManager->generateEvent(); $activityEvent->setApp(Application::ID); diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 207e21c..348d22f 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -51,14 +51,14 @@ class Application extends App { } } - private function registerAsPersonalSetting() { + private function registerAsPersonalSetting(): void { /** @var ISettingsManager */ $settingsManager = $this->getContainer()->query(ISettingsManager::class); $settingsManager->registerSetting(ISettingsManager::KEY_PERSONAL_SETTINGS, \OCA\BigBlueButton\Settings\Personal::class); } - private function registerAsNavigationEntry(string $name) { + private function registerAsNavigationEntry(string $name): void { $server = $this->getContainer()->getServer(); $server->getNavigationManager()->add(function () use ($server, $name) { @@ -72,7 +72,7 @@ class Application extends App { }); } - private function registerServiceListener(IEventDispatcher $dispatcher) { + private function registerServiceListener(IEventDispatcher $dispatcher): void { $dispatcher->addServiceListener(RoomCreatedEvent::class, RoomListener::class); $dispatcher->addServiceListener(RoomDeletedEvent::class, RoomListener::class); diff --git a/lib/BigBlueButton/API.php b/lib/BigBlueButton/API.php index a9b6eca..cb1e008 100644 --- a/lib/BigBlueButton/API.php +++ b/lib/BigBlueButton/API.php @@ -56,7 +56,7 @@ class API { $this->urlHelper = $urlHelper; } - private function getServer() { + private function getServer(): BigBlueButton { if (!$this->server) { $apiUrl = $this->config->getAppValue('bbb', 'api.url'); $secret = $this->config->getAppValue('bbb', 'api.secret'); @@ -175,7 +175,7 @@ class API { return $this->recordToArray($records[0]); } - public function getRecordings(Room $room) { + public function getRecordings(Room $room): array { $recordingParams = new GetRecordingsParameters(); $recordingParams->setMeetingId($room->uid); $recordingParams->setState('processing,processed,published,unpublished'); @@ -201,7 +201,12 @@ class API { return $response->isDeleted(); } - private function recordToArray(Record $record) { + /** + * @return (array|bool|int|string)[] + * + * @psalm-return array{id: string, meetingId: string, name: string, published: bool, state: string, startTime: string, participants: int, type: string, length: string, url: string, metas: array} + */ + private function recordToArray(Record $record): array { return [ 'id' => $record->getRecordId(), 'meetingId' => $record->getMeetingId(), @@ -217,7 +222,7 @@ class API { ]; } - public function check(string $url, string $secret) { + public function check(string $url, string $secret): string { $server = new BigBlueButton($url, $secret); $meetingParams = new IsMeetingRunningParameters('foobar'); diff --git a/lib/BigBlueButton/Presentation.php b/lib/BigBlueButton/Presentation.php index 558c260..028c48d 100644 --- a/lib/BigBlueButton/Presentation.php +++ b/lib/BigBlueButton/Presentation.php @@ -12,15 +12,15 @@ class Presentation { $this->filename = $filename; } - public function getUrl() { + public function getUrl(): string { return $this->url; } - public function getFilename() { + public function getFilename(): string { return $this->filename; } - public function isValid() { + public function isValid(): bool { return !empty($this->url) && !empty($this->filename); } } diff --git a/lib/Controller/HookController.php b/lib/Controller/HookController.php index 857092a..3769b32 100644 --- a/lib/Controller/HookController.php +++ b/lib/Controller/HookController.php @@ -35,7 +35,7 @@ class HookController extends Controller { $this->eventDispatcher = $eventDispatcher; } - public function setToken(string $token) { + public function setToken(string $token): void { $this->token = $token; $this->room = null; } @@ -48,9 +48,12 @@ class HookController extends Controller { /** * @PublicPage + * * @NoCSRFRequired + * + * @return void */ - public function meetingEnded($recordingmarks = false) { + public function meetingEnded($recordingmarks = false): void { $recordingmarks = \boolval($recordingmarks); $this->eventDispatcher->dispatch(MeetingEndedEvent::class, new MeetingEndedEvent($this->getRoom(), $recordingmarks)); @@ -58,9 +61,12 @@ class HookController extends Controller { /** * @PublicPage + * * @NoCSRFRequired + * + * @return void */ - public function recordingReady() { + public function recordingReady(): void { $this->eventDispatcher->dispatch(RecordingReadyEvent::class, new RecordingReadyEvent($this->getRoom())); } diff --git a/lib/Controller/JoinController.php b/lib/Controller/JoinController.php index 53a2430..3816ab7 100644 --- a/lib/Controller/JoinController.php +++ b/lib/Controller/JoinController.php @@ -56,7 +56,7 @@ class JoinController extends Controller { $this->permission = $permission; } - public function setToken(string $token) { + public function setToken(string $token): void { $this->token = $token; $this->room = null; } @@ -69,7 +69,10 @@ class JoinController extends Controller { /** * @PublicPage + * * @NoCSRFRequired + * + * @return RedirectResponse|TemplateResponse */ public function index($displayname, $u = '', $filename = '', $password = '') { $room = $this->getRoom(); diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index e66d213..cc4bbb5 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -4,6 +4,7 @@ namespace OCA\BigBlueButton\Controller; use OCA\BigBlueButton\TemplateProvider; use OCP\AppFramework\Controller; +use OCP\AppFramework\Http\TemplateResponse; use OCP\IRequest; class PageController extends Controller { @@ -18,9 +19,12 @@ class PageController extends Controller { /** * @NoAdminRequired + * * @NoCSRFRequired + * + * @return TemplateResponse */ - public function index() { + public function index(): TemplateResponse { return $this->templateProvider->getManager(); } } diff --git a/lib/Controller/ServerController.php b/lib/Controller/ServerController.php index a0d075d..3ffc0d3 100644 --- a/lib/Controller/ServerController.php +++ b/lib/Controller/ServerController.php @@ -80,7 +80,7 @@ class ServerController extends Controller { return new DataResponse($success); } - public function check(?string $url, ?string $secret) { + public function check(?string $url, ?string $secret): DataResponse { if ($url === null || empty($url) || $secret === null || empty($secret)) { return new DataResponse(false); } @@ -88,7 +88,7 @@ class ServerController extends Controller { return new DataResponse($this->server->check($url, $secret)); } - public function version(?string $url) { + public function version(?string $url): DataResponse { if ($url === null || empty($url)) { return new DataResponse(false, Http::STATUS_NOT_FOUND); } diff --git a/lib/Crypto.php b/lib/Crypto.php index 03f5dc0..5e2213b 100644 --- a/lib/Crypto.php +++ b/lib/Crypto.php @@ -22,7 +22,7 @@ class Crypto { return $this->encodeBase64UrlSafe(\sha1($this->crypto->calculateHMAC($message), true)); } - public function verifyHMAC(string $message, string $mac) { + public function verifyHMAC(string $message, string $mac): bool { if ($message === null || $mac === null) { return false; } @@ -32,6 +32,9 @@ class Crypto { return $validMac === $mac; } + /** + * @return false|string + */ private function encodeBase64UrlSafe(string $data) { $b64 = \base64_encode($data); diff --git a/lib/Listener/UserDeletedListener.php b/lib/Listener/UserDeletedListener.php index aba00e0..3825b60 100644 --- a/lib/Listener/UserDeletedListener.php +++ b/lib/Listener/UserDeletedListener.php @@ -46,7 +46,7 @@ class UserDeletedListener implements IEventListener { } } - private function deleteSharesByRoomId(string $roomId) { + private function deleteSharesByRoomId(string $roomId): void { $shares = $this->shareService->findAll($roomId); foreach ($shares as $share) { @@ -54,7 +54,7 @@ class UserDeletedListener implements IEventListener { } } - private function deleteSharesByUserId(string $userId) { + private function deleteSharesByUserId(string $userId): void { $shares = $this->shareService->findByUserId($userId); foreach ($shares as $share) { diff --git a/lib/Middleware/HookMiddleware.php b/lib/Middleware/HookMiddleware.php index e2b702d..5dec6cf 100644 --- a/lib/Middleware/HookMiddleware.php +++ b/lib/Middleware/HookMiddleware.php @@ -23,6 +23,9 @@ class HookMiddleware extends Middleware { $this->crypto = $crypto; } + /** + * @return void + */ public function beforeController($controller, $methodName) { if (!($controller instanceof HookController)) { return; diff --git a/lib/Middleware/JoinMiddleware.php b/lib/Middleware/JoinMiddleware.php index 5a33d47..89f3c20 100644 --- a/lib/Middleware/JoinMiddleware.php +++ b/lib/Middleware/JoinMiddleware.php @@ -18,6 +18,9 @@ class JoinMiddleware extends Middleware { $this->request = $request; } + /** + * @return void + */ public function beforeController($controller, $methodName) { if (!($controller instanceof JoinController)) { return; diff --git a/lib/Permission.php b/lib/Permission.php index 20a7741..ef89698 100644 --- a/lib/Permission.php +++ b/lib/Permission.php @@ -55,20 +55,20 @@ class Permission { return $this->restrictionService->findByGroupIds($groupIds); } - public function isAllowedToCreateRoom(string $uid) { + public function isAllowedToCreateRoom(string $uid): bool { $numberOfCreatedRooms = count($this->roomService->findAll($uid, [], [])); $restriction = $this->getRestriction($uid); return $restriction->getMaxRooms() < 0 || $restriction->getMaxRooms() > $numberOfCreatedRooms; } - public function isUser(Room $room, ?string $uid) { + public function isUser(Room $room, ?string $uid): bool { return $this->hasPermission($room, $uid, function (RoomShare $share) { return $share->hasUserPermission(); }); } - public function isModerator(Room $room, ?string $uid) { + public function isModerator(Room $room, ?string $uid): bool { if ($room->everyoneIsModerator) { return true; } @@ -78,7 +78,7 @@ class Permission { }); } - public function isAdmin(Room $room, ?string $uid) { + public function isAdmin(Room $room, ?string $uid): bool { return $this->hasPermission($room, $uid, function (RoomShare $share) { return $share->hasAdminPermission(); }); diff --git a/lib/Service/RoomService.php b/lib/Service/RoomService.php index e0523af..77f60c4 100644 --- a/lib/Service/RoomService.php +++ b/lib/Service/RoomService.php @@ -57,7 +57,7 @@ class RoomService { } } - public function findByUid(string $uid) { + public function findByUid(string $uid): ?Room { try { return $this->mapper->findByUid($uid); } catch (Exception $e) { @@ -66,7 +66,7 @@ class RoomService { } } - public function create(string $name, string $welcome, int $maxParticipants, bool $record, string $access, string $userId) { + public function create(string $name, string $welcome, int $maxParticipants, bool $record, string $access, string $userId): \OCP\AppFramework\Db\Entity { $room = new Room(); $room->setUid(\OC::$server->getSecureRandom()->generate(16, \OCP\Security\ISecureRandom::CHAR_HUMAN_READABLE)); @@ -92,6 +92,8 @@ class RoomService { /** * @param null|string $moderatorToken + * + * @return \OCP\AppFramework\Db\Entity|null */ public function update(int $id, string $name, string $welcome, int $maxParticipants, bool $record, string $access, bool $everyoneIsModerator, bool $requireModerator, ?string $moderatorToken) { try { @@ -119,6 +121,9 @@ class RoomService { } } + /** + * @return Room|null + */ public function delete(int $id) { try { $room = $this->mapper->find($id); diff --git a/lib/Settings/Section.php b/lib/Settings/Section.php index 9e7edd0..ed9d0db 100644 --- a/lib/Settings/Section.php +++ b/lib/Settings/Section.php @@ -21,7 +21,7 @@ class Section implements IIconSection { * returns the ID of the section. It is supposed to be a lower case string, * e.g. 'ldap' * - * @returns string + * @return string */ public function getID() { return 'bbb'; @@ -50,6 +50,8 @@ class Section implements IIconSection { /** * {@inheritdoc} + * + * @return string */ public function getIcon() { return $this->url->imagePath('bbb', 'app-dark.svg');