Skip to content

Commit

Permalink
chore: Run php cs fixer
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Aug 26, 2024
1 parent 77289d9 commit bafea52
Show file tree
Hide file tree
Showing 23 changed files with 88 additions and 87 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
->notPath('build')
->notPath('l10n')
->notPath('src')
->notPath('node_modules')
->notPath('vendor')
->in(__DIR__);
return $config;
2 changes: 1 addition & 1 deletion lib/Controller/APIv1Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function getSinceFromOffset($offset) {
$result->closeCursor();

if ($row) {
return (int) $row['activity_id'];
return (int)$row['activity_id'];
}

return 0;
Expand Down
16 changes: 8 additions & 8 deletions lib/Controller/APIv2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ protected function validateParameters($filter, $since, $limit, $previews, $objec
if ($this->filter !== $this->data->validateFilter($this->filter)) {
throw new InvalidFilterException('Invalid filter');
}
$this->since = (int) $since;
$this->limit = (int) $limit;
$this->loadPreviews = (bool) $previews;
$this->objectType = (string) $objectType;
$this->objectId = (int) $objectId;
$this->since = (int)$since;
$this->limit = (int)$limit;
$this->loadPreviews = (bool)$previews;
$this->objectType = (string)$objectType;
$this->objectId = (int)$objectId;
$this->sort = \in_array($sort, ['asc', 'desc'], true) ? $sort : 'desc';

if (($this->objectType !== '' && $this->objectId === 0) || ($this->objectType === '' && $this->objectId !== 0)) {
Expand Down Expand Up @@ -223,15 +223,15 @@ protected function get($filter, $since, $limit, $previews, $filterObjectType, $f
if ($activity['object_type'] === 'files') {
if (!empty($activity['objects']) && \is_array($activity['objects'])) {
foreach ($activity['objects'] as $objectId => $objectName) {
if (((int) $objectId) === 0 || $objectName === '') {
if (((int)$objectId) === 0 || $objectName === '') {
// No file, no preview
continue;
}

$activity['previews'][] = $this->getPreview($activity['affecteduser'], (int) $objectId, $objectName);
$activity['previews'][] = $this->getPreview($activity['affecteduser'], (int)$objectId, $objectName);
}
} elseif ($activity['object_id']) {
$activity['previews'][] = $this->getPreview($activity['affecteduser'], (int) $activity['object_id'], $activity['object_name']);
$activity['previews'][] = $this->getPreview($activity['affecteduser'], (int)$activity['object_id'], $activity['object_name']);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Controller/ActivitiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ protected function getLinkList(): array {
$filters = $this->activityManager->getFilters();
usort($filters, static function (IFilter $a, IFilter $b) {
if ($a->getPriority() === $b->getPriority()) {
return (int) ($a->getIdentifier() > $b->getIdentifier());
return (int)($a->getIdentifier() > $b->getIdentifier());
}

return (int) ($a->getPriority() > $b->getPriority());
return (int)($a->getPriority() > $b->getPriority());
});

$entries = [];
Expand Down
18 changes: 9 additions & 9 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
protected IL10N $l10n,
CurrentUser $currentUser) {
parent::__construct($appName, $request);
$this->user = (string) $currentUser->getUID();
$this->user = (string)$currentUser->getUID();
}

/**
Expand All @@ -55,14 +55,14 @@ public function personal(
$this->config->setUserValue(
$this->user, 'activity',
'notify_notification_' . $setting->getIdentifier(),
(string)(int) $this->request->getParam($setting->getIdentifier() . '_notification', false)
(string)(int)$this->request->getParam($setting->getIdentifier() . '_notification', false)
);

if ($setting->canChangeMail()) {
$this->config->setUserValue(
$this->user, 'activity',
'notify_email_' . $setting->getIdentifier(),
(string)(int) $this->request->getParam($setting->getIdentifier() . '_email', false)
(string)(int)$this->request->getParam($setting->getIdentifier() . '_email', false)
);
}
}
Expand All @@ -84,17 +84,17 @@ public function personal(
$this->config->setUserValue(
$this->user, 'activity',
'notify_setting_self',
(string)(int) $notify_setting_self
(string)(int)$notify_setting_self
);
$this->config->setUserValue(
$this->user, 'activity',
'notify_setting_selfemail',
(string)(int) $notify_setting_selfemail
(string)(int)$notify_setting_selfemail
);
$this->config->setUserValue(
$this->user, 'activity',
'notify_setting_activity_digest',
(string)(int) $activity_digest
(string)(int)$activity_digest
);

return new DataResponse([
Expand Down Expand Up @@ -126,7 +126,7 @@ public function admin(
$this->config->setAppValue(
'activity',
'notify_email_' . $setting->getIdentifier(),
(string)(int) $this->request->getParam($setting->getIdentifier() . '_email', false)
(string)(int)$this->request->getParam($setting->getIdentifier() . '_email', false)
);
}
}
Expand All @@ -148,12 +148,12 @@ public function admin(
$this->config->setAppValue(
'activity',
'notify_setting_self',
(string)(int) $notify_setting_self
(string)(int)$notify_setting_self
);
$this->config->setAppValue(
'activity',
'notify_setting_selfemail',
(string)(int) $notify_setting_selfemail
(string)(int)$notify_setting_selfemail
);

return new DataResponse([
Expand Down
4 changes: 2 additions & 2 deletions lib/CurrentUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getUID() {
if ($this->sessionUser === false) {
$user = $this->userSession->getUser();
if ($user instanceof IUser) {
$this->sessionUser = (string) $user->getUID();
$this->sessionUser = (string)$user->getUID();
} else {
$this->sessionUser = null;
}
Expand All @@ -85,7 +85,7 @@ public function getCloudId() {
if ($this->cloudId === false) {
$user = $this->userSession->getUser();
if ($user instanceof IUser) {
$this->cloudId = (string) $user->getCloudId();
$this->cloudId = (string)$user->getCloudId();
} else {
$this->cloudId = $this->getCloudIDFromToken();
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Dashboard/ActivityWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
$this->helper,
$this->settings,
$userId,
$since ? (int) $since : 0,
$since ? (int)$since : 0,
50,
'desc',
'by',
Expand All @@ -122,7 +122,7 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7):
$this->dateTimeFormatter->formatTimeSpan($activity['timestamp']),
$activity['link'],
$activity['icon'],
(string) $activity['activity_id']
(string)$activity['activity_id']
);
}, array_slice($activities['data'], 0, $limit));
}
Expand All @@ -137,7 +137,7 @@ public function getItemsV2(string $userId, ?string $since = null, int $limit = 7
$this->helper,
$this->settings,
$userId,
$since ? (int) $since : 0,
$since ? (int)$since : 0,
50,
'desc',
'by',
Expand All @@ -160,7 +160,7 @@ public function getItemsV2(string $userId, ?string $since = null, int $limit = 7
$this->dateTimeFormatter->formatTimeSpan($activity['timestamp']),
$activity['link'],
$userAvatarUrl,
(string) $activity['activity_id'],
(string)$activity['activity_id'],
$activity['icon'],
);
}, array_slice($activities['data'], 0, $limit));
Expand Down
4 changes: 2 additions & 2 deletions lib/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,8 @@ public function expire($expireDays = 365) {
* Delete activities that match certain conditions
*
* @param array $conditions Array with conditions that have to be met
* 'field' => 'value' => `field` = 'value'
* 'field' => array('value', 'operator') => `field` operator 'value'
* 'field' => 'value' => `field` = 'value'
* 'field' => array('value', 'operator') => `field` operator 'value'
*/
public function deleteActivities($conditions): void {
$platform = $this->connection->getDatabasePlatform();
Expand Down
10 changes: 5 additions & 5 deletions lib/DigestSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ public function sendDigestForUser(string $uid, int $now, string $timezone, strin
$this->activityManager->setCurrentUserId($uid);

['count' => $count, 'max' => $lastActivityId] = $this->data->getActivitySince($uid, $lastSend, true);
$count = (int) $count;
$lastActivityId = (int) $lastActivityId;
$count = (int)$count;
$lastActivityId = (int)$lastActivityId;
if ($count === 0) {
return;
}
Expand Down Expand Up @@ -181,7 +181,7 @@ public function sendDigestForUser(string $uid, int $now, string $timezone, strin
$this->activityManager->setCurrentUserId(null);
try {
$this->mailer->send($message);
$this->config->setUserValue($user->getUID(), 'activity', 'activity_digest_last_send', (string) $lastActivityId);
$this->config->setUserValue($user->getUID(), 'activity', 'activity_digest_last_send', (string)$lastActivityId);
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
return;
Expand All @@ -202,9 +202,9 @@ protected function getHTMLSubject(IEvent $event): string {
$placeholders[] = '{' . $placeholder . '}';

if ($parameter['type'] === 'file') {
$replacement = (string) $parameter['path'];
$replacement = (string)$parameter['path'];
} else {
$replacement = (string) $parameter['name'];
$replacement = (string)$parameter['name'];
}

if (isset($parameter['link'])) {
Expand Down
16 changes: 8 additions & 8 deletions lib/FilesHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ protected function shareWithUser($shareWith, $fileSource, $itemType, $fileTarget
$shareWith, 'shared_with_by', [[$fileSource => $fileTarget], $this->currentUser->getUserIdentifier()],
(int)$fileSource, $fileTarget, $itemType === 'file',
$this->userSettings->getUserSetting($shareWith, 'email', Files_Sharing::TYPE_SHARED) ? $this->userSettings->getUserSetting($shareWith, 'setting', 'batchtime') : false,
(bool) $this->userSettings->getUserSetting($shareWith, 'notification', Files_Sharing::TYPE_SHARED)
(bool)$this->userSettings->getUserSetting($shareWith, 'notification', Files_Sharing::TYPE_SHARED)
);
}

Expand Down Expand Up @@ -754,7 +754,7 @@ protected function shareByLink($fileSource, $itemType, $linkOwner) {
$linkOwner, 'shared_link_self', [[$fileSource => $path]],
(int)$fileSource, $path, $itemType === 'file',
$this->userSettings->getUserSetting($linkOwner, 'email', Files_Sharing::TYPE_SHARED) ? $this->userSettings->getUserSetting($linkOwner, 'setting', 'batchtime') : false,
(bool) $this->userSettings->getUserSetting($linkOwner, 'notification', Files_Sharing::TYPE_SHARED)
(bool)$this->userSettings->getUserSetting($linkOwner, 'notification', Files_Sharing::TYPE_SHARED)
);
}

Expand Down Expand Up @@ -827,7 +827,7 @@ protected function unshareFromUser(IShare $share) {
$share->getSharedWith(), $actionUser, [[$share->getNodeId() => $share->getTarget()], $this->currentUser->getUserIdentifier()],
$share->getNodeId(), $share->getTarget(), $share->getNodeType() === 'file',
$this->userSettings->getUserSetting($share->getSharedWith(), 'email', Files_Sharing::TYPE_SHARED) ? $this->userSettings->getUserSetting($share->getSharedWith(), 'setting', 'batchtime') : false,
(bool) $this->userSettings->getUserSetting($share->getSharedWith(), 'notification', Files_Sharing::TYPE_SHARED)
(bool)$this->userSettings->getUserSetting($share->getSharedWith(), 'notification', Files_Sharing::TYPE_SHARED)
);
}

Expand Down Expand Up @@ -880,7 +880,7 @@ protected function unshareFromGroup(IShare $share) {
$users = $group->searchUsers('', self::USER_BATCH_SIZE, $offset);
$shouldFlush = $this->startActivityTransaction();
while (!empty($users)) {
$this->addNotificationsForGroupUsers($users, $actionUser, $share->getNodeId(), $share->getNodeType(), $share->getTarget(), (int) $share->getId());
$this->addNotificationsForGroupUsers($users, $actionUser, $share->getNodeId(), $share->getNodeType(), $share->getTarget(), (int)$share->getId());
$offset += self::USER_BATCH_SIZE;
$users = $group->searchUsers('', self::USER_BATCH_SIZE, $offset);
}
Expand Down Expand Up @@ -925,7 +925,7 @@ protected function unshareLink(IShare $share) {
$owner, $actionSharer, [[$share->getNodeId() => $share->getTarget()]],
$share->getNodeId(), $share->getTarget(), $share->getNodeType() === 'file',
$this->userSettings->getUserSetting($owner, 'email', Files_Sharing::TYPE_SHARED) ? $this->userSettings->getUserSetting($owner, 'setting', 'batchtime') : false,
(bool) $this->userSettings->getUserSetting($owner, 'notification', Files_Sharing::TYPE_SHARED)
(bool)$this->userSettings->getUserSetting($owner, 'notification', Files_Sharing::TYPE_SHARED)
);

if ($share->getSharedBy() !== $share->getShareOwner()) {
Expand All @@ -934,7 +934,7 @@ protected function unshareLink(IShare $share) {
$owner, $actionOwner, [[$share->getNodeId() => $share->getTarget()], $share->getSharedBy()],
$share->getNodeId(), $share->getTarget(), $share->getNodeType() === 'file',
$this->userSettings->getUserSetting($owner, 'email', Files_Sharing::TYPE_SHARED) ? $this->userSettings->getUserSetting($owner, 'setting', 'batchtime') : false,
(bool) $this->userSettings->getUserSetting($owner, 'notification', Files_Sharing::TYPE_SHARED)
(bool)$this->userSettings->getUserSetting($owner, 'notification', Files_Sharing::TYPE_SHARED)
);
}
}
Expand Down Expand Up @@ -1027,7 +1027,7 @@ protected function shareNotificationForSharer($subject, $shareWith, $fileSource,
$sharer, $subject, [[$fileSource => $path], $shareWith],
$fileSource, $path, ($itemType === 'file'),
$this->userSettings->getUserSetting($sharer, 'email', Files_Sharing::TYPE_SHARED) ? $this->userSettings->getUserSetting($sharer, 'setting', 'batchtime') : false,
(bool) $this->userSettings->getUserSetting($sharer, 'notification', Files_Sharing::TYPE_SHARED)
(bool)$this->userSettings->getUserSetting($sharer, 'notification', Files_Sharing::TYPE_SHARED)
);
}

Expand All @@ -1053,7 +1053,7 @@ protected function reshareNotificationForSharer($owner, $subject, $shareWith, $f
$owner, $subject, [[$fileSource => $path], $this->currentUser->getUserIdentifier(), $shareWith],
$fileSource, $path, ($itemType === 'file'),
$this->userSettings->getUserSetting($owner, 'email', Files_Sharing::TYPE_SHARED) ? $this->userSettings->getUserSetting($owner, 'setting', 'batchtime') : false,
(bool) $this->userSettings->getUserSetting($owner, 'notification', Files_Sharing::TYPE_SHARED)
(bool)$this->userSettings->getUserSetting($owner, 'notification', Files_Sharing::TYPE_SHARED)
);
}

Expand Down
20 changes: 10 additions & 10 deletions lib/GroupHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function setL10n(IL10N $l): void {
* Add an activity to the internal array
*/
public function addActivity(array $activity): void {
$id = (int) $activity['activity_id'];
$id = (int)$activity['activity_id'];
$event = $this->arrayToEvent($activity);
$this->addEvent($id, $event);
}
Expand Down Expand Up @@ -142,15 +142,15 @@ public function getEvents(): array {

protected function arrayToEvent(array $row): IEvent {
$event = $this->activityManager->generateEvent();
$event->setApp((string) $row['app'])
->setType((string) $row['type'])
->setAffectedUser((string) $row['affecteduser'])
->setAuthor((string) $row['user'])
->setTimestamp((int) $row['timestamp'])
->setSubject((string) $row['subject'], (array) json_decode($row['subjectparams'], true))
->setMessage((string) $row['message'], (array) json_decode($row['messageparams'], true))
->setObject((string) $row['object_type'], (int) $row['object_id'], (string) $row['file'])
->setLink((string) $row['link']);
$event->setApp((string)$row['app'])
->setType((string)$row['type'])
->setAffectedUser((string)$row['affecteduser'])
->setAuthor((string)$row['user'])
->setTimestamp((int)$row['timestamp'])
->setSubject((string)$row['subject'], (array)json_decode($row['subjectparams'], true))
->setMessage((string)$row['message'], (array)json_decode($row['messageparams'], true))
->setObject((string)$row['object_type'], (int)$row['object_id'], (string)$row['file'])
->setLink((string)$row['link']);

return $event;
}
Expand Down
16 changes: 8 additions & 8 deletions lib/MailQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ protected function sendEmailToUser(string $userName, string $email, string $lang
foreach ($mailData as $activity) {
$event = $this->activityManager->generateEvent();
try {
$event->setApp((string) $activity['amq_appid'])
->setType((string) $activity['amq_type'])
->setAffectedUser((string) $activity['amq_affecteduser'])
->setTimestamp((int) $activity['amq_timestamp'])
->setSubject((string) $activity['amq_subject'], (array) json_decode($activity['amq_subjectparams'], true))
->setObject((string) $activity['object_type'], (int) $activity['object_id']);
$event->setApp((string)$activity['amq_appid'])
->setType((string)$activity['amq_type'])
->setAffectedUser((string)$activity['amq_affecteduser'])
->setTimestamp((int)$activity['amq_timestamp'])
->setSubject((string)$activity['amq_subject'], (array)json_decode($activity['amq_subjectparams'], true))
->setObject((string)$activity['object_type'], (int)$activity['object_id']);
} catch (\InvalidArgumentException $e) {
continue;
}
Expand Down Expand Up @@ -365,9 +365,9 @@ protected function getHTMLSubject(IEvent $event): string {
$placeholders[] = '{' . $placeholder . '}';

if ($parameter['type'] === 'file') {
$replacement = (string) $parameter['path'];
$replacement = (string)$parameter['path'];
} else {
$replacement = (string) $parameter['name'];
$replacement = (string)$parameter['name'];
}

if (isset($parameter['link'])) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version2006Date20170919095939.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
class Version2006Date20170919095939 extends BigIntMigration {
/**
* @return array Returns an array with the following structure
* ['table1' => ['column1', 'column2'], ...]
* ['table1' => ['column1', 'column2'], ...]
* @since 13.0.0
*/
protected function getColumnsByTable() {
Expand Down
Loading

0 comments on commit bafea52

Please sign in to comment.