Skip to content

Commit

Permalink
Remove unneeded casts that were found by Psalm
Browse files Browse the repository at this point in the history
In preparation of the update of Psalm from 4.2.1 to 4.3.1+ (see #24521)

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Jan 11, 2021
1 parent 8b656e3 commit 31ca28d
Show file tree
Hide file tree
Showing 41 changed files with 173 additions and 175 deletions.
2 changes: 1 addition & 1 deletion apps/comments/lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ protected function getSubjectParameters(IEvent $event) {
// they will get the dead entries in their stream.
return [
'actor' => $subjectParameters[0],
'fileId' => (int) $event->getObjectId(),
'fileId' => $event->getObjectId(),
'filePath' => trim($subjectParameters[1], '/'),
];
}
Expand Down
10 changes: 5 additions & 5 deletions apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,32 +229,32 @@ protected function getParameters(IEvent $event) {
case self::SUBJECT_UNSHARE_USER . '_self':
return [
'actor' => $this->generateUserParameter($parameters[0]),
'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'calendar' => $this->generateLegacyCalendarParameter($event->getObjectId(), $parameters[1]),
];
case self::SUBJECT_SHARE_USER . '_you':
case self::SUBJECT_UNSHARE_USER . '_you':
return [
'user' => $this->generateUserParameter($parameters[0]),
'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'calendar' => $this->generateLegacyCalendarParameter($event->getObjectId(), $parameters[1]),
];
case self::SUBJECT_SHARE_USER . '_by':
case self::SUBJECT_UNSHARE_USER . '_by':
return [
'user' => $this->generateUserParameter($parameters[0]),
'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'calendar' => $this->generateLegacyCalendarParameter($event->getObjectId(), $parameters[1]),
'actor' => $this->generateUserParameter($parameters[2]),
];
case self::SUBJECT_SHARE_GROUP . '_you':
case self::SUBJECT_UNSHARE_GROUP . '_you':
return [
'group' => $this->generateGroupParameter($parameters[0]),
'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'calendar' => $this->generateLegacyCalendarParameter($event->getObjectId(), $parameters[1]),
];
case self::SUBJECT_SHARE_GROUP . '_by':
case self::SUBJECT_UNSHARE_GROUP . '_by':
return [
'group' => $this->generateGroupParameter($parameters[0]),
'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'calendar' => $this->generateLegacyCalendarParameter($event->getObjectId(), $parameters[1]),
'actor' => $this->generateUserParameter($parameters[2]),
];
}
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/Activity/Provider/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ protected function getParameters(IEvent $event) {
case self::SUBJECT_OBJECT_UPDATE . '_event':
return [
'actor' => $this->generateUserParameter($parameters[0]),
'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'calendar' => $this->generateLegacyCalendarParameter($event->getObjectId(), $parameters[1]),
'event' => $this->generateObjectParameter($parameters[2]),
];
case self::SUBJECT_OBJECT_ADD . '_event_self':
case self::SUBJECT_OBJECT_DELETE . '_event_self':
case self::SUBJECT_OBJECT_UPDATE . '_event_self':
return [
'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'calendar' => $this->generateLegacyCalendarParameter($event->getObjectId(), $parameters[1]),
'event' => $this->generateObjectParameter($parameters[2]),
];
}
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/Activity/Provider/Todo.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected function getParameters(IEvent $event) {
case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action':
return [
'actor' => $this->generateUserParameter($parameters[0]),
'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'calendar' => $this->generateLegacyCalendarParameter($event->getObjectId(), $parameters[1]),
'todo' => $this->generateObjectParameter($parameters[2]),
];
case self::SUBJECT_OBJECT_ADD . '_todo_self':
Expand All @@ -136,7 +136,7 @@ protected function getParameters(IEvent $event) {
case self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self':
case self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self':
return [
'calendar' => $this->generateLegacyCalendarParameter((int)$event->getObjectId(), $parameters[1]),
'calendar' => $this->generateLegacyCalendarParameter($event->getObjectId(), $parameters[1]),
'todo' => $this->generateObjectParameter($parameters[2]),
];
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function propFind(PropFind $propFind, INode $node) {
$canPublish &= ($node->getOwner() === $node->getPrincipalURI());
}

return new AllowedSharingModes((bool)$canShare, (bool)$canPublish);
return new AllowedSharingModes($canShare, $canPublish);
});
}
}
Expand Down
34 changes: 17 additions & 17 deletions apps/encryption/lib/Controller/RecoveryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,36 +75,36 @@ public function __construct($AppName,
public function adminRecovery($recoveryPassword, $confirmPassword, $adminEnableRecovery) {
// Check if both passwords are the same
if (empty($recoveryPassword)) {
$errorMessage = (string)$this->l->t('Missing recovery key password');
$errorMessage = $this->l->t('Missing recovery key password');
return new DataResponse(['data' => ['message' => $errorMessage]],
Http::STATUS_BAD_REQUEST);
}

if (empty($confirmPassword)) {
$errorMessage = (string)$this->l->t('Please repeat the recovery key password');
$errorMessage = $this->l->t('Please repeat the recovery key password');
return new DataResponse(['data' => ['message' => $errorMessage]],
Http::STATUS_BAD_REQUEST);
}

if ($recoveryPassword !== $confirmPassword) {
$errorMessage = (string)$this->l->t('Repeated recovery key password does not match the provided recovery key password');
$errorMessage = $this->l->t('Repeated recovery key password does not match the provided recovery key password');
return new DataResponse(['data' => ['message' => $errorMessage]],
Http::STATUS_BAD_REQUEST);
}

if (isset($adminEnableRecovery) && $adminEnableRecovery === '1') {
if ($this->recovery->enableAdminRecovery($recoveryPassword)) {
return new DataResponse(['data' => ['message' => (string)$this->l->t('Recovery key successfully enabled')]]);
return new DataResponse(['data' => ['message' => $this->l->t('Recovery key successfully enabled')]]);
}
return new DataResponse(['data' => ['message' => (string)$this->l->t('Could not enable recovery key. Please check your recovery key password!')]], Http::STATUS_BAD_REQUEST);
return new DataResponse(['data' => ['message' => $this->l->t('Could not enable recovery key. Please check your recovery key password!')]], Http::STATUS_BAD_REQUEST);
} elseif (isset($adminEnableRecovery) && $adminEnableRecovery === '0') {
if ($this->recovery->disableAdminRecovery($recoveryPassword)) {
return new DataResponse(['data' => ['message' => (string)$this->l->t('Recovery key successfully disabled')]]);
return new DataResponse(['data' => ['message' => $this->l->t('Recovery key successfully disabled')]]);
}
return new DataResponse(['data' => ['message' => (string)$this->l->t('Could not disable recovery key. Please check your recovery key password!')]], Http::STATUS_BAD_REQUEST);
return new DataResponse(['data' => ['message' => $this->l->t('Could not disable recovery key. Please check your recovery key password!')]], Http::STATUS_BAD_REQUEST);
}
// this response should never be sent but just in case.
return new DataResponse(['data' => ['message' => (string)$this->l->t('Missing parameters')]], Http::STATUS_BAD_REQUEST);
return new DataResponse(['data' => ['message' => $this->l->t('Missing parameters')]], Http::STATUS_BAD_REQUEST);
}

/**
Expand All @@ -116,22 +116,22 @@ public function adminRecovery($recoveryPassword, $confirmPassword, $adminEnableR
public function changeRecoveryPassword($newPassword, $oldPassword, $confirmPassword) {
//check if both passwords are the same
if (empty($oldPassword)) {
$errorMessage = (string)$this->l->t('Please provide the old recovery password');
$errorMessage = $this->l->t('Please provide the old recovery password');
return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST);
}

if (empty($newPassword)) {
$errorMessage = (string)$this->l->t('Please provide a new recovery password');
$errorMessage = $this->l->t('Please provide a new recovery password');
return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST);
}

if (empty($confirmPassword)) {
$errorMessage = (string)$this->l->t('Please repeat the new recovery password');
$errorMessage = $this->l->t('Please repeat the new recovery password');
return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST);
}

if ($newPassword !== $confirmPassword) {
$errorMessage = (string)$this->l->t('Repeated recovery key password does not match the provided recovery key password');
$errorMessage = $this->l->t('Repeated recovery key password does not match the provided recovery key password');
return new DataResponse(['data' => ['message' => $errorMessage]], Http::STATUS_BAD_REQUEST);
}

Expand All @@ -142,14 +142,14 @@ public function changeRecoveryPassword($newPassword, $oldPassword, $confirmPassw
return new DataResponse(
[
'data' => [
'message' => (string)$this->l->t('Password successfully changed.')]
'message' => $this->l->t('Password successfully changed.')]
]
);
}
return new DataResponse(
[
'data' => [
'message' => (string)$this->l->t('Could not change the password. Maybe the old password was not correct.')
'message' => $this->l->t('Could not change the password. Maybe the old password was not correct.')
]
], Http::STATUS_BAD_REQUEST);
}
Expand All @@ -169,22 +169,22 @@ public function userSetRecovery($userEnableRecovery) {
return new DataResponse(
[
'data' => [
'message' => (string)$this->l->t('Recovery Key disabled')]
'message' => $this->l->t('Recovery Key disabled')]
]
);
}
return new DataResponse(
[
'data' => [
'message' => (string)$this->l->t('Recovery Key enabled')]
'message' => $this->l->t('Recovery Key enabled')]
]
);
}
}
return new DataResponse(
[
'data' => [
'message' => (string)$this->l->t('Could not enable the recovery key, please try again or contact your administrator')
'message' => $this->l->t('Could not enable the recovery key, please try again or contact your administrator')
]
], Http::STATUS_BAD_REQUEST);
}
Expand Down
4 changes: 2 additions & 2 deletions apps/encryption/lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ public function updatePrivateKeyPassword($oldPassword, $newPassword) {
if ($result === true) {
$this->session->setStatus(Session::INIT_SUCCESSFUL);
return new DataResponse(
['message' => (string) $this->l->t('Private key password successfully updated.')]
['message' => $this->l->t('Private key password successfully updated.')]
);
} else {
return new DataResponse(
['message' => (string) $errorMessage],
['message' => $errorMessage],
Http::STATUS_BAD_REQUEST
);
}
Expand Down
8 changes: 4 additions & 4 deletions apps/encryption/lib/Controller/StatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,25 @@ public function getStatus() {
switch ($this->session->getStatus()) {
case Session::INIT_EXECUTED:
$status = 'interactionNeeded';
$message = (string)$this->l->t(
$message = $this->l->t(
'Invalid private key for encryption app. Please update your private key password in your personal settings to recover access to your encrypted files.'
);
break;
case Session::NOT_INITIALIZED:
$status = 'interactionNeeded';
if ($this->encryptionManager->isEnabled()) {
$message = (string)$this->l->t(
$message = $this->l->t(
'Encryption App is enabled, but your keys are not initialized. Please log-out and log-in again.'
);
} else {
$message = (string)$this->l->t(
$message = $this->l->t(
'Please enable server side encryption in the admin settings in order to use the encryption module.'
);
}
break;
case Session::INIT_SUCCESSFUL:
$status = 'success';
$message = (string)$this->l->t('Encryption app is enabled and ready');
$message = $this->l->t('Encryption app is enabled and ready');
}

return new DataResponse(
Expand Down
2 changes: 1 addition & 1 deletion apps/encryption/lib/Crypto/EncryptAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ protected function sendPasswordsByMail() {
continue;
}

$subject = (string)$this->l->t('one-time password for server-side-encryption');
$subject = $this->l->t('one-time password for server-side-encryption');
list($htmlBody, $textBody) = $this->createMailBody($password);

// send it out now
Expand Down
4 changes: 2 additions & 2 deletions apps/federatedfilesharing/lib/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ public function prepare(INotification $notification, string $languageCode): INot
switch ($action->getLabel()) {
case 'accept':
$action->setParsedLabel(
(string)$l->t('Accept')
$l->t('Accept')
)
->setPrimary(true);
break;

case 'decline':
$action->setParsedLabel(
(string)$l->t('Decline')
$l->t('Decline')
);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/federation/lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function addServer($url) {
[
'url' => $url,
'id' => $id,
'message' => (string) $this->l->t('Added to the list of trusted servers')
'message' => $this->l->t('Added to the list of trusted servers')
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/files/lib/Controller/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function toggleShowFolder(int $show, string $key) {
foreach ($navItems as $item) {
// check if data is valid
if (($show === 0 || $show === 1) && isset($item['expandedState']) && $key === $item['expandedState']) {
$this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', $key, (int)$show);
$this->config->setUserValue($this->userSession->getUser()->getUID(), 'files', $key, $show);
return new Response();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function update(
} catch (NotFoundException $e) {
return new DataResponse(
[
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id])
'message' => $this->l10n->t('Storage with ID "%d" not found', [$id])
],
Http::STATUS_NOT_FOUND
);
Expand Down
20 changes: 10 additions & 10 deletions apps/files_external/lib/Controller/StoragesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected function createStorage(
$this->logger->logException($e);
return new DataResponse(
[
'message' => (string)$this->l10n->t('Invalid backend or authentication mechanism class')
'message' => $this->l10n->t('Invalid backend or authentication mechanism class')
],
Http::STATUS_UNPROCESSABLE_ENTITY
);
Expand All @@ -164,7 +164,7 @@ protected function validate(StorageConfig $storage) {
if ($mountPoint === '') {
return new DataResponse(
[
'message' => (string)$this->l10n->t('Invalid mount point'),
'message' => $this->l10n->t('Invalid mount point'),
],
Http::STATUS_UNPROCESSABLE_ENTITY
);
Expand All @@ -174,7 +174,7 @@ protected function validate(StorageConfig $storage) {
// objectstore must not be sent from client side
return new DataResponse(
[
'message' => (string)$this->l10n->t('Objectstore forbidden'),
'message' => $this->l10n->t('Objectstore forbidden'),
],
Http::STATUS_UNPROCESSABLE_ENTITY
);
Expand All @@ -188,7 +188,7 @@ protected function validate(StorageConfig $storage) {
// invalid backend
return new DataResponse(
[
'message' => (string)$this->l10n->t('Invalid storage backend "%s"', [
'message' => $this->l10n->t('Invalid storage backend "%s"', [
$backend->getIdentifier(),
]),
],
Expand All @@ -200,7 +200,7 @@ protected function validate(StorageConfig $storage) {
// not permitted to use backend
return new DataResponse(
[
'message' => (string)$this->l10n->t('Not permitted to use backend "%s"', [
'message' => $this->l10n->t('Not permitted to use backend "%s"', [
$backend->getIdentifier(),
]),
],
Expand All @@ -211,7 +211,7 @@ protected function validate(StorageConfig $storage) {
// not permitted to use auth mechanism
return new DataResponse(
[
'message' => (string)$this->l10n->t('Not permitted to use authentication mechanism "%s"', [
'message' => $this->l10n->t('Not permitted to use authentication mechanism "%s"', [
$authMechanism->getIdentifier(),
]),
],
Expand All @@ -223,7 +223,7 @@ protected function validate(StorageConfig $storage) {
// unsatisfied parameters
return new DataResponse(
[
'message' => (string)$this->l10n->t('Unsatisfied backend parameters'),
'message' => $this->l10n->t('Unsatisfied backend parameters'),
],
Http::STATUS_UNPROCESSABLE_ENTITY
);
Expand All @@ -232,7 +232,7 @@ protected function validate(StorageConfig $storage) {
// unsatisfied parameters
return new DataResponse(
[
'message' => (string)$this->l10n->t('Unsatisfied authentication mechanism parameters'),
'message' => $this->l10n->t('Unsatisfied authentication mechanism parameters'),
],
Http::STATUS_UNPROCESSABLE_ENTITY
);
Expand Down Expand Up @@ -347,7 +347,7 @@ public function show($id, $testOnly = true) {
} catch (NotFoundException $e) {
return new DataResponse(
[
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]),
'message' => $this->l10n->t('Storage with ID "%d" not found', [$id]),
],
Http::STATUS_NOT_FOUND
);
Expand Down Expand Up @@ -376,7 +376,7 @@ public function destroy($id) {
} catch (NotFoundException $e) {
return new DataResponse(
[
'message' => (string)$this->l10n->t('Storage with ID "%d" not found', [$id]),
'message' => $this->l10n->t('Storage with ID "%d" not found', [$id]),
],
Http::STATUS_NOT_FOUND
);
Expand Down
Loading

0 comments on commit 31ca28d

Please sign in to comment.