diff options
author | Joas Schilling <coding@schilljs.com> | 2022-09-29 11:31:45 +0300 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2022-09-29 19:27:59 +0300 |
commit | cceb2a2182dd7a4356ae5a9e7cd6eff8ee2507a7 (patch) | |
tree | d8176210ce18d04b24f80466e0e494f0b392fb8d | |
parent | 87448e3ed2377dbb3dd1eebe140dcb070ef7bd4b (diff) |
Fix CS and psalm
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/Collaboration/Reference/TalkReferenceProvider.php | 8 | ||||
-rw-r--r-- | tests/php/Collaboration/Reference/TalkReferenceProviderTest.php | 12 |
2 files changed, 5 insertions, 15 deletions
diff --git a/lib/Collaboration/Reference/TalkReferenceProvider.php b/lib/Collaboration/Reference/TalkReferenceProvider.php index 5b171471a..f3b0b1ba2 100644 --- a/lib/Collaboration/Reference/TalkReferenceProvider.php +++ b/lib/Collaboration/Reference/TalkReferenceProvider.php @@ -40,7 +40,7 @@ use OCP\IL10N; use OCP\IURLGenerator; /** - * @psalm-type ReferenceMatch = array{token: string, message: ?int} + * @psalm-type ReferenceMatch = array{token: string, message: int|null} */ class TalkReferenceProvider implements IReferenceProvider { protected IURLGenerator $urlGenerator; @@ -79,9 +79,9 @@ class TalkReferenceProvider implements IReferenceProvider { $rewriteUrl = $this->urlGenerator->getAbsoluteURL('/call/'); if (str_starts_with($referenceText, $indexPhpUrl)) { - $urlOfInterest = substr($referenceText, strlen($indexPhpUrl)) ?: null; + $urlOfInterest = substr($referenceText, strlen($indexPhpUrl)); } elseif (str_starts_with($referenceText, $rewriteUrl)) { - $urlOfInterest = substr($referenceText, strlen($rewriteUrl)) ?: null; + $urlOfInterest = substr($referenceText, strlen($rewriteUrl)); } else { return null; } @@ -178,7 +178,7 @@ class TalkReferenceProvider implements IReferenceProvider { * Description is the plain text chat message */ if ($participant && !empty($referenceMatch['message'])) { - $comment = $this->chatManager->getComment($room, $referenceMatch['message']); + $comment = $this->chatManager->getComment($room, (string) $referenceMatch['message']); $message = $this->messageParser->createMessage($room, $participant, $comment, $this->l); $this->messageParser->parseMessage($message); diff --git a/tests/php/Collaboration/Reference/TalkReferenceProviderTest.php b/tests/php/Collaboration/Reference/TalkReferenceProviderTest.php index f9ab9e751..08c86db95 100644 --- a/tests/php/Collaboration/Reference/TalkReferenceProviderTest.php +++ b/tests/php/Collaboration/Reference/TalkReferenceProviderTest.php @@ -27,19 +27,9 @@ namespace OCA\Talk\Tests\php\Collaboration\Resources; use OCA\Talk\Chat\ChatManager; use OCA\Talk\Chat\MessageParser; use OCA\Talk\Collaboration\Reference\TalkReferenceProvider; -use OCA\Talk\Collaboration\Resources\ConversationProvider; -use OCA\Talk\Exceptions\ParticipantNotFoundException; -use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Manager; -use OCA\Talk\Model\Attendee; -use OCA\Talk\Participant; -use OCA\Talk\Room; -use OCP\Collaboration\Resources\IResource; -use OCP\Collaboration\Resources\ResourceException; use OCP\IL10N; use OCP\IURLGenerator; -use OCP\IUser; -use OCP\IUserSession; use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; @@ -97,7 +87,7 @@ class TalkReferenceProviderTest extends TestCase { public function testGetTalkAppLinkToken(string $reference, ?array $expected): void { $this->urlGenerator->expects($this->any()) ->method('getAbsoluteURL') - ->willReturnCallback(static fn($url) => 'https://localhost' . $url); + ->willReturnCallback(static fn ($url) => 'https://localhost' . $url); $actual = self::invokePrivate($this->provider, 'getTalkAppLinkToken', [$reference]); self::assertSame($expected, $actual); |