diff --git a/lib/App.php b/lib/App.php index 4207d0ea..ab2c02c0 100644 --- a/lib/App.php +++ b/lib/App.php @@ -69,7 +69,7 @@ public function markProcessed(INotification $notification): void { } foreach ($deleted as $user => $notifications) { foreach ($notifications as $data) { - $this->push->pushDeleteToDevice((string) $user, [$data['id']], $data['app']); + $this->push->pushDeleteToDevice((string)$user, [$data['id']], $data['app']); } } if (!$isAlreadyDeferring) { diff --git a/lib/BackgroundJob/GenerateUserSettings.php b/lib/BackgroundJob/GenerateUserSettings.php index 8d32a943..efc37e07 100644 --- a/lib/BackgroundJob/GenerateUserSettings.php +++ b/lib/BackgroundJob/GenerateUserSettings.php @@ -49,7 +49,7 @@ protected function run($argument): void { ->setMaxResults(1); $result = $query->executeQuery(); - $maxId = (int) $result->fetchOne(); + $maxId = (int)$result->fetchOne(); $result->closeCursor(); $this->userManager->callForSeenUsers(function (IUser $user) use ($maxId) { diff --git a/lib/Command/Generate.php b/lib/Command/Generate.php index 25f41e3e..f9cbfd2a 100644 --- a/lib/Command/Generate.php +++ b/lib/Command/Generate.php @@ -99,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $subjectTitle = 'cli'; } else { - $subject = (int) $subject; + $subject = (int)$subject; $subjectTitle = 'dummy'; } diff --git a/lib/Controller/APIController.php b/lib/Controller/APIController.php index b7584760..f132df14 100644 --- a/lib/Controller/APIController.php +++ b/lib/Controller/APIController.php @@ -150,6 +150,6 @@ public function generateNotificationV3( return new DataResponse(['error' => $e->getMessage()], Http::STATUS_BAD_REQUEST); } - return new DataResponse(['id' => (int) $this->notificationApp->getLastInsertedId()]); + return new DataResponse(['id' => (int)$this->notificationApp->getLastInsertedId()]); } } diff --git a/lib/Controller/EndpointController.php b/lib/Controller/EndpointController.php index f0eb6184..5d282437 100644 --- a/lib/Controller/EndpointController.php +++ b/lib/Controller/EndpointController.php @@ -196,7 +196,7 @@ public function confirmIdsForUser(string $apiVersion, array $ids): DataResponse } $ids = array_unique(array_filter(array_map( - static fn ($id) => is_numeric($id) ? (int) $id : 0, + static fn ($id) => is_numeric($id) ? (int)$id : 0, $ids ))); @@ -333,6 +333,6 @@ protected function getCurrentUser(): string { $user = $user->getUID(); } - return (string) $user; + return (string)$user; } } diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 42028456..0327cfc0 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -63,7 +63,7 @@ public function personal(int $batchSetting, string $soundNotification, string $s */ #[OpenAPI(scope: OpenAPI::SCOPE_ADMINISTRATION)] public function admin(int $batchSetting, string $soundNotification, string $soundTalk): DataResponse { - $this->config->setAppValue(Application::APP_ID, 'setting_batchtime', (string) $batchSetting); + $this->config->setAppValue(Application::APP_ID, 'setting_batchtime', (string)$batchSetting); $this->config->setAppValue(Application::APP_ID, 'sound_notification', $soundNotification !== 'no' ? 'yes' : 'no'); $this->config->setAppValue(Application::APP_ID, 'sound_talk', $soundTalk !== 'no' ? 'yes' : 'no'); diff --git a/lib/Handler.php b/lib/Handler.php index 011db638..d0f85cc0 100644 --- a/lib/Handler.php +++ b/lib/Handler.php @@ -59,7 +59,7 @@ public function count(INotification $notification): int { $this->sqlWhere($sql, $notification); $statement = $sql->executeQuery(); - $count = (int) $statement->fetchOne(); + $count = (int)$statement->fetchOne(); $statement->closeCursor(); return $count; @@ -87,10 +87,10 @@ public function delete(INotification $notification): array { } $deleted[$row['user']][] = [ - 'id' => (int) $row['notification_id'], + 'id' => (int)$row['notification_id'], 'app' => $row['app'], ]; - $notifications[(int) $row['notification_id']] = $this->notificationFromRow($row); + $notifications[(int)$row['notification_id']] = $this->notificationFromRow($row); } $statement->closeCursor(); @@ -159,7 +159,7 @@ public function deleteById(int $id, string $user, ?INotification $notification = $sql->delete('notifications') ->where($sql->expr()->eq('notification_id', $sql->createNamedParameter($id))) ->andWhere($sql->expr()->eq('user', $sql->createNamedParameter($user))); - return (bool) $sql->executeStatement(); + return (bool)$sql->executeStatement(); } /** @@ -220,7 +220,7 @@ public function confirmIdsForUser(string $user, array $ids): array { $existing = []; while ($row = $result->fetch()) { - $existing[] = (int) $row['notification_id']; + $existing[] = (int)$row['notification_id']; } $result->closeCursor(); @@ -366,17 +366,17 @@ protected function sqlInsert(IQueryBuilder $sql, INotification $notification) { */ protected function notificationFromRow(array $row): INotification { $dateTime = new \DateTime(); - $dateTime->setTimestamp((int) $row['timestamp']); + $dateTime->setTimestamp((int)$row['timestamp']); $notification = $this->manager->createNotification(); $notification->setApp($row['app']) ->setUser($row['user']) ->setDateTime($dateTime) ->setObject($row['object_type'], $row['object_id']) - ->setSubject($row['subject'], (array) json_decode($row['subject_parameters'], true)); + ->setSubject($row['subject'], (array)json_decode($row['subject_parameters'], true)); if ($row['message'] !== '' && $row['message'] !== null) { - $notification->setMessage($row['message'], (array) json_decode($row['message_parameters'], true)); + $notification->setMessage($row['message'], (array)json_decode($row['message_parameters'], true)); } if ($row['link'] !== '' && $row['link'] !== null) { $notification->setLink($row['link']); @@ -385,7 +385,7 @@ protected function notificationFromRow(array $row): INotification { $notification->setIcon($row['icon']); } - $actions = (array) json_decode($row['actions'], true); + $actions = (array)json_decode($row['actions'], true); foreach ($actions as $actionData) { $action = $notification->createAction(); $action->setLabel($actionData['label']) diff --git a/lib/Listener/PostLoginListener.php b/lib/Listener/PostLoginListener.php index 8e50ea45..8395ad12 100644 --- a/lib/Listener/PostLoginListener.php +++ b/lib/Listener/PostLoginListener.php @@ -43,7 +43,7 @@ public function handle(Event $event): void { } catch (DoesNotExistException $e) { $defaultSoundNotification = $this->config->getAppValue(Application::APP_ID, 'sound_notification') === 'yes' ? 'yes' : 'no'; $defaultSoundTalk = $this->config->getAppValue(Application::APP_ID, 'sound_talk') === 'yes' ? 'yes' : 'no'; - $defaultBatchtime = (int) $this->config->getAppValue(Application::APP_ID, 'setting_batchtime'); + $defaultBatchtime = (int)$this->config->getAppValue(Application::APP_ID, 'setting_batchtime'); if ($defaultBatchtime !== Settings::EMAIL_SEND_WEEKLY && $defaultBatchtime !== Settings::EMAIL_SEND_DAILY diff --git a/lib/Listener/UserCreatedListener.php b/lib/Listener/UserCreatedListener.php index e2711f7a..b087130f 100644 --- a/lib/Listener/UserCreatedListener.php +++ b/lib/Listener/UserCreatedListener.php @@ -39,7 +39,7 @@ public function handle(Event $event): void { $defaultSoundNotification = $this->config->getAppValue(Application::APP_ID, 'sound_notification') === 'yes' ? 'yes' : 'no'; $defaultSoundTalk = $this->config->getAppValue(Application::APP_ID, 'sound_talk') === 'yes' ? 'yes' : 'no'; - $defaultBatchtime = (int) $this->config->getAppValue(Application::APP_ID, 'setting_batchtime'); + $defaultBatchtime = (int)$this->config->getAppValue(Application::APP_ID, 'setting_batchtime'); if ($defaultBatchtime !== Settings::EMAIL_SEND_WEEKLY && $defaultBatchtime !== Settings::EMAIL_SEND_DAILY diff --git a/lib/Migration/Version2010Date20210218082811.php b/lib/Migration/Version2010Date20210218082811.php index c594ab90..ac99e466 100644 --- a/lib/Migration/Version2010Date20210218082811.php +++ b/lib/Migration/Version2010Date20210218082811.php @@ -117,7 +117,7 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array while ($row = $result->fetch()) { $insert ->setParameter('uid', $row['uid']) - ->setParameter('token', (int) $row['token'], IQueryBuilder::PARAM_INT) + ->setParameter('token', (int)$row['token'], IQueryBuilder::PARAM_INT) ->setParameter('deviceidentifier', $row['deviceidentifier']) ->setParameter('devicepublickey', $row['devicepublickey']) ->setParameter('devicepublickeyhash', $row['devicepublickeyhash']) diff --git a/lib/Model/SettingsMapper.php b/lib/Model/SettingsMapper.php index 61030997..2bb28ec9 100644 --- a/lib/Model/SettingsMapper.php +++ b/lib/Model/SettingsMapper.php @@ -113,10 +113,10 @@ public function getUsersByNextSendTime(int $limit): array { public function createSettingsFromRow(array $row): Settings { return $this->mapRowToEntity([ 'id' => $row['id'], - 'user_id' => (string) $row['user_id'], - 'batch_time' => (int) $row['batch_time'], - 'last_send_id' => (int) $row['last_send_id'], - 'next_send_time' => (int) $row['next_send_time'], + 'user_id' => (string)$row['user_id'], + 'batch_time' => (int)$row['batch_time'], + 'last_send_id' => (int)$row['last_send_id'], + 'next_send_time' => (int)$row['next_send_time'], ]); } } diff --git a/lib/Notifier/AdminNotifications.php b/lib/Notifier/AdminNotifications.php index 510f2dfd..2e0caa72 100644 --- a/lib/Notifier/AdminNotifications.php +++ b/lib/Notifier/AdminNotifications.php @@ -63,7 +63,7 @@ public function prepare(INotification $notification, string $languageCode): INot switch ($notification->getSubject()) { case 'dummy': $subjectParams = $notification->getSubjectParameters(); - $numActions = (int) $subjectParams[0]; + $numActions = (int)$subjectParams[0]; $user = $this->userManager->get($notification->getUser()); assert($user instanceof IUser); diff --git a/lib/Push.php b/lib/Push.php index 64b62943..fa296c51 100644 --- a/lib/Push.php +++ b/lib/Push.php @@ -181,7 +181,7 @@ public function flushPayloads(): void { if (!empty($this->deleteAllsToPush)) { foreach ($this->deleteAllsToPush as $userId => $bool) { - $this->pushDeleteToDevice((string) $userId, null); + $this->pushDeleteToDevice((string)$userId, null); } $this->deleteAllsToPush = []; } @@ -190,10 +190,10 @@ public function flushPayloads(): void { foreach ($this->deletesToPush as $userId => $data) { foreach ($data as $client => $notificationIds) { if ($client === 'talk') { - $this->pushDeleteToDevice((string) $userId, $notificationIds, $client); + $this->pushDeleteToDevice((string)$userId, $notificationIds, $client); } else { foreach ($notificationIds as $notificationId) { - $this->pushDeleteToDevice((string) $userId, [$notificationId], $client); + $this->pushDeleteToDevice((string)$userId, [$notificationId], $client); } } } @@ -318,7 +318,7 @@ public function pushToDevice(int $id, INotification $notification, ?OutputInterf $maxAge = time() - 60 * 24 * 60 * 60; foreach ($devices as $device) { - $device['token'] = (int) $device['token']; + $device['token'] = (int)$device['token']; $this->printInfo(''); $this->printInfo('Device token:' . $device['token']); @@ -411,7 +411,7 @@ public function pushDeleteToDevice(string $userId, ?array $notificationIds, stri $userKey = $this->keyManager->getKey($user); foreach ($devices as $device) { - $device['token'] = (int) $device['token']; + $device['token'] = (int)$device['token']; if (!$this->validateToken($device['token'], $maxAge)) { // Token does not exist anymore continue; @@ -488,7 +488,7 @@ protected function sendNotificationsToProxies(): void { $response = $client->post($proxyServer . '/notifications', $requestData); $status = $response->getStatusCode(); - $body = (string) $response->getBody(); + $body = (string)$response->getBody(); try { $bodyData = json_decode($body, true); } catch (\JsonException $e) { @@ -544,7 +544,7 @@ protected function sendNotificationsToProxies(): void { } } elseif ($status !== Http::STATUS_OK) { if ($status === Http::STATUS_TOO_MANY_REQUESTS) { - $this->config->setAppValue(Application::APP_ID, 'rate_limit_reached', (string) $this->timeFactory->getTime()); + $this->config->setAppValue(Application::APP_ID, 'rate_limit_reached', (string)$this->timeFactory->getTime()); } $error = $body && $bodyData === null ? $body : 'no reason given'; $this->printInfo('Could not send notification to push server [' . $proxyServer . ']: ' . $error); diff --git a/lib/Settings/Admin.php b/lib/Settings/Admin.php index fe59a6c0..4092808a 100644 --- a/lib/Settings/Admin.php +++ b/lib/Settings/Admin.php @@ -30,7 +30,7 @@ public function getForm(): TemplateResponse { $defaultSoundNotification = $this->config->getAppValue(Application::APP_ID, 'sound_notification') === 'yes' ? 'yes' : 'no'; $defaultSoundTalk = $this->config->getAppValue(Application::APP_ID, 'sound_talk') === 'yes' ? 'yes' : 'no'; - $defaultBatchtime = (int) $this->config->getAppValue(Application::APP_ID, 'setting_batchtime'); + $defaultBatchtime = (int)$this->config->getAppValue(Application::APP_ID, 'setting_batchtime'); if ($defaultBatchtime !== Settings::EMAIL_SEND_WEEKLY && $defaultBatchtime !== Settings::EMAIL_SEND_DAILY @@ -59,8 +59,8 @@ public function getSection(): string { /** * @return int whether the form should be rather on the top or bottom of - * the admin section. The forms are arranged in ascending order of the - * priority values. It is required to return a value between 0 and 100. + * the admin section. The forms are arranged in ascending order of the + * priority values. It is required to return a value between 0 and 100. * * E.g.: 70 */ diff --git a/lib/Settings/AdminSection.php b/lib/Settings/AdminSection.php index 784a103a..9677ffd1 100644 --- a/lib/Settings/AdminSection.php +++ b/lib/Settings/AdminSection.php @@ -57,8 +57,8 @@ public function getName(): string { /** * @return int whether the form should be rather on the top or bottom of - * the settings navigation. The sections are arranged in ascending order of - * the priority values. It is required to return a value between 0 and 99. + * the settings navigation. The sections are arranged in ascending order of + * the priority values. It is required to return a value between 0 and 99. * * E.g.: 70 * @since 9.1 diff --git a/lib/Settings/Personal.php b/lib/Settings/Personal.php index fe5bfe6d..de3738e7 100644 --- a/lib/Settings/Personal.php +++ b/lib/Settings/Personal.php @@ -103,8 +103,8 @@ public function getSection(): string { /** * @return int whether the form should be rather on the top or bottom of - * the admin section. The forms are arranged in ascending order of the - * priority values. It is required to return a value between 0 and 100. + * the admin section. The forms are arranged in ascending order of the + * priority values. It is required to return a value between 0 and 100. * * E.g.: 70 */ diff --git a/lib/Settings/PersonalSection.php b/lib/Settings/PersonalSection.php index 6d78e109..7db23bdb 100644 --- a/lib/Settings/PersonalSection.php +++ b/lib/Settings/PersonalSection.php @@ -60,8 +60,8 @@ public function getName(): string { /** * @return int whether the form should be rather on the top or bottom of - * the settings navigation. The sections are arranged in ascending order of - * the priority values. It is required to return a value between 0 and 99. + * the settings navigation. The sections are arranged in ascending order of + * the priority values. It is required to return a value between 0 and 99. * * E.g.: 70 * @since 9.1 diff --git a/lib/Settings/SetupWarningOnRateLimitReached.php b/lib/Settings/SetupWarningOnRateLimitReached.php index b4e7c90c..abc6b54c 100644 --- a/lib/Settings/SetupWarningOnRateLimitReached.php +++ b/lib/Settings/SetupWarningOnRateLimitReached.php @@ -42,7 +42,7 @@ public function getName(): string { * @inheritDoc */ public function run(): SetupResult { - $lastReached = (int) $this->config->getAppValue(Application::APP_ID, 'rate_limit_reached', '0'); + $lastReached = (int)$this->config->getAppValue(Application::APP_ID, 'rate_limit_reached', '0'); if ($lastReached < ($this->timeFactory->getTime() - 7 * 24 * 3600)) { return SetupResult::success(); } diff --git a/tests/Integration/features/bootstrap/FeatureContext.php b/tests/Integration/features/bootstrap/FeatureContext.php index 9e14aec7..ed2c20ad 100644 --- a/tests/Integration/features/bootstrap/FeatureContext.php +++ b/tests/Integration/features/bootstrap/FeatureContext.php @@ -121,11 +121,11 @@ public function checkResponseBodyIsEmpty() { */ public function checkNumNotifications(int $numNotifications) { $notifications = $this->getArrayOfNotificationsResponded($this->response); - Assert::assertCount((int) $numNotifications, $notifications); + Assert::assertCount((int)$numNotifications, $notifications); $notificationIds = []; foreach ($notifications as $notification) { - $notificationIds[] = (int) $notification['notification_id']; + $notificationIds[] = (int)$notification['notification_id']; } $this->notificationIds[] = $notificationIds; @@ -182,7 +182,7 @@ public function userNumNotifications(string $user, int $numNotifications, string $previousNotificationIds = end($this->notificationIds); } - $this->checkNumNotifications((int) $numNotifications); + $this->checkNumNotifications((int)$numNotifications); if ($missingLast) { $now = end($this->notificationIds);