Skip to content

Commit ed80527

Browse files
committed
Fix types warnings from psalm
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
1 parent 7ecb65f commit ed80527

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

apps/sharebymail/lib/ShareByMailProvider.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,13 @@ protected function createMailShare(IShare $share) {
334334
$share->getNote()
335335
);
336336

337-
if ($this->mailer->validateMailAddress($share->getSharedWith())) {
337+
if (!$this->mailer->validateMailAddress($share->getSharedWith())) {
338338
$this->removeShareFromTable($shareId);
339339
$e = new HintException('Failed to send share by mail. Got an invalid email address: ' . $share->getSharedWith(),
340340
$this->l->t('Failed to send share by email. Got an invalid email address'));
341-
$this->logger->error($e->getMessage(), [
342-
'message' => 'Failed to send share by mail. Got an invalid email address ' . $share->getSharedWith(),
341+
$this->logger->error('Failed to send share by mail. Got an invalid email address ' . $share->getSharedWith(), [
343342
'app' => 'sharebymail',
343+
'exception' => $e,
344344
]);
345345
}
346346

@@ -689,7 +689,7 @@ public function getChildren(IShare $parent) {
689689
* @param \DateTime|null $expirationTime
690690
* @return int
691691
*/
692-
protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload, $label, $expirationTime, $note = '') {
692+
protected function addShareToDB($itemSource, $itemType, $shareWith, $sharedBy, $uidOwner, $permissions, $token, $password, $sendPasswordByTalk, $hideDownload, $label, $expirationTime, $note = ''): int {
693693
$qb = $this->dbConnection->getQueryBuilder();
694694
$qb->insert('share')
695695
->setValue('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL))
@@ -784,7 +784,7 @@ public function delete(IShare $share) {
784784
} catch (\Exception $e) {
785785
}
786786

787-
$this->removeShareFromTable($share->getId());
787+
$this->removeShareFromTable((int)$share->getId());
788788
}
789789

790790
/**
@@ -980,9 +980,9 @@ public function getShareByToken($token) {
980980
/**
981981
* remove share from table
982982
*
983-
* @param string $shareId
983+
* @param int $shareId
984984
*/
985-
protected function removeShareFromTable($shareId) {
985+
protected function removeShareFromTable(int $shareId): void {
986986
$qb = $this->dbConnection->getQueryBuilder();
987987
$qb->delete('share')
988988
->where($qb->expr()->eq('id', $qb->createNamedParameter($shareId)));

apps/sharebymail/tests/ShareByMailProviderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ public function testCreateMailShare() {
465465

466466
$instance = $this->getInstance(['generateToken', 'addShareToDB', 'sendMailNotification']);
467467

468+
$instance->expects($this->once())->method('getSharedWith')->willReturn(['valid@valid.com']);
468469
$instance->expects($this->once())->method('generateToken')->willReturn('token');
469470
$instance->expects($this->once())->method('addShareToDB')->willReturn(42);
470471
$instance->expects($this->once())->method('sendMailNotification');

0 commit comments

Comments
 (0)